1

Mono を使用して、Mac 上で .net 2 Windows.Forms アプリケーションを実行しようとしています。アプリケーションには、事前定義されたデフォルトがあり、ユーザーが再構成できるすべての機能のキーの組み合わせのショートカットがあります。Form KeyDown イベント ハンドラーは、実行するアクションを検索します。

私の問題は、Modifiers と KeyCode を実際に押されたキーに関連付けることです。Mac 用にマッピングを追加する必要があるかどうかは気にしませんが、少なくとも 3 つの修飾キーが必要です。ただし、Mac の 4 つの修飾子のうち、明らかな結果が得られるものはほとんどないようです。Shift - 期待どおりに動作します Ctrl - 別の KeyCode を報告しますが、正しい修飾子を使用します (たとえば、Ctrl+N には Modifiers = Control と KeyCode 14 = "RButton, Clear" があります)。
Alt - 変更されていない他のキーを報告します (例: Alt+R は KeyCode = 168 = "BrowserRefresh" を返します)

Cmd キーは通常、Windows で Ctrl が使用される場所で使用されると思います。3 つの Mac キーのどれを使用しようとすべきか、だれかアドバイスしてもらえますか? 最も重要なのは、KeyEventArgs を解析して、ベース キーと 3 つのオプションの修飾子を一貫して報告する方法です。

Mono は最新バージョン (1、2 週間前の時点) で、違いがあるとすれば MacBook Air、OS X 10.8.1 です。

4

2 に答える 2

1

In case it's useful to anyone, this is where I ended up: I eventually managed to hack my way around this particular 'feature' by creating a new KeyData value to replace the one provided by the event (this code running only if it's a Mac). I swapped round some of the modifiers to make it more consistent with windows (ie if Cmd was pressed, and reported as Alt by Mono I changed that to Ctrl). I also filtered out ctrl+A to ctrl+Z which return KeyCodes 0 to 25 (not 65 to 90) and replaced these with their normal values. Fortunately my code only wanted the KeyData. It wouldn't be possible to create a new KeyEventArgs using the updated data, since Mono checks the current keyboard state and sets modifier flags for any pressed modifier keys, in addition to any modifiers passed to the KeyEventArgs constructor.

BUT - as ruffin commented Mono on the Mac is very flaky. We've parked this work for the moment as it's taking quite a bit of time to work around all the problems. So far we've managed to find a solution for each item we've looked at, and may well come back to this - but at best it will be a nasty hack to get this S/W running on the Mac.

于 2012-09-24T11:53:15.140 に答える
1

同じ問題が発生します。IRC を使用して、部屋の Mono と MonoMac について irc.gnome.org で質問してみてください。とても親切な方々。

どうやらMonoMacを使用すると、Interface Builder でネイティブ UI を構築でき、バックエンドの C# コードをスタブ化してそれと通信することができます (つまり、MonoMac は、Mac で実行されているMonoではなく、ネイティブ Mac と通信する Monoです。2 番目は単純です) Mono)、Windows.Forms のサポートは途中で終了しました -- Windows.Forms は Mac では本質的に「死んでいる」と言われましたが、静かなbugzilla ページはそれをサポートしているようです。それは本当にかなりバグです。SelectionBackColor がすぐに RichTextBox で機能しないことに遭遇し、メニュー アクセラレータが確実に機能しなくなりました。Mac 上の Windows.Forms は、アルファからベータの品質だと思います。

とは言っても、本質的に愛情のこもった作業のために、驚くほど多くの Windows.Forms がうまく機能しますが、洗練されたアプリには使用しません。幸運を。

編集: OP が特にメニューアイテムについて話していなかったことに気付きましたが、関連するバグについて話すために、アクセラレータとメニューアイテムがうまく機能しないというバグレポートがあります。

[単バグ] [Bug 75996][Maj] 新規 - ショートカットによってトリガーされない menuitem イベント

Mono 上の Windows.Forms はもうすぐ機能するので、必要なことをサポートしてくれると考えたくなりますが、簡単なユーティリティを作成する以上の使用に十分な信頼性があると考えるのは間違いです。

于 2012-09-15T03:01:53.467 に答える