「Xamarin.Mac/カスタムURLスキームを利用する」の版間の差分
imported>Administrator 編集の要約なし |
imported>Administrator |
||
| 2行目: | 2行目: | ||
== 実装 == | == 実装 == | ||
=== カスタムURLスキームを有効にする === | |||
以下でカスタムURLスキームが利用可能になる。 | 以下でカスタムURLスキームが利用可能になる。 | ||
# Xamarin Studioでプロジェクト内の「Info.plist」を開く | # Xamarin Studioでプロジェクト内の「Info.plist」を開く | ||
| 9行目: | 10行目: | ||
# 「URL Schems」にURLスキーム名を入れる(例:monobook) | # 「URL Schems」にURLスキーム名を入れる(例:monobook) | ||
=== カスタムURLスキームで呼ばれるメソッドを作る === | |||
次にURLスキームが叩かれた際に呼ばれるメソッドの登録と実装をする。 | 次にURLスキームが叩かれた際に呼ばれるメソッドの登録と実装をする。 | ||
<source lang="csharp"> | <source lang="csharp"> | ||
| 31行目: | 33行目: | ||
{ | { | ||
// URLスキームで呼ばれるメソッドを指定する。 | // URLスキームで呼ばれるメソッドを指定する。 | ||
// Export("handleGetURLEvent:withReplyEvent:")属性が付いたメソッドが呼ばれる。 | |||
var appleEventManager = NSAppleEventManager.SharedAppleEventManager; | var appleEventManager = NSAppleEventManager.SharedAppleEventManager; | ||
appleEventManager.SetEventHandler(this | appleEventManager.SetEventHandler(this | ||
| 62行目: | 65行目: | ||
/// <summary> | /// <summary> | ||
/// Xamarin. | /// NSAppleEventDescriptorのParamDescriptorForKeywordメソッドに指定する定数。 | ||
/// Xamarin.Macに定数らしきものが見当たらなかったのでxcode眺めつつ作った。 | |||
/// </summary> | /// </summary> | ||
public static class AEKeyword | public static class AEKeyword | ||
| 88行目: | 92行目: | ||
</source> | </source> | ||
=== デバッグ === | |||
ターミナルでopenコマンドを叩けば簡単に[[デバッグ]]できる。openの引数(URLスキーム)にアンパサンド(&)を含む場合はダブルクォーテーション(")で囲むこと。 | |||
open "monobook://" | open "monobook://" | ||
open "monobook://inbox" | open "monobook://inbox" | ||