OSDN Git Service

PostBrowserの標準のショートカットキーの動作を一部有効にする
authorKimura Youichi <kim.upsilon@bucyou.net>
Fri, 6 Mar 2015 12:00:45 +0000 (21:00 +0900)
committerKimura Youichi <kim.upsilon@bucyou.net>
Fri, 6 Mar 2015 14:40:48 +0000 (23:40 +0900)
従来 WebBrowserShortcutsEnabled を false にした上で Ctrl+C など一部のショートカットキーの動作を CommonKeyDown メソッドで再現していたが、
WebBrowserShortcutsEnabled を true にしたまま特定のショートカットキー以外の入力を無効にすることで標準の挙動を生かした。
これにより絵文字を含むテキストが正常にコピーされない問題が回避できる。

OpenTween/Tween.Designer.cs
OpenTween/Tween.cs

index 2b0aa99..5ede193 100644 (file)
             this.PostBrowser.IsWebBrowserContextMenuEnabled = false;
             this.PostBrowser.Name = "PostBrowser";
             this.PostBrowser.TabStop = false;
-            this.PostBrowser.WebBrowserShortcutsEnabled = false;
             this.PostBrowser.Navigated += new System.Windows.Forms.WebBrowserNavigatedEventHandler(this.PostBrowser_Navigated);
             this.PostBrowser.Navigating += new System.Windows.Forms.WebBrowserNavigatingEventHandler(this.PostBrowser_Navigating);
             this.PostBrowser.StatusTextChanged += new System.EventHandler(this.PostBrowser_StatusTextChanged);
index 572cafc..1e06c6c 100644 (file)
@@ -6847,24 +6847,6 @@ namespace OpenTween
                         //フォーカスPostBrowserもしくは関係なし
                         switch (KeyCode)
                         {
-                            case Keys.A:
-                                PostBrowser.Document.ExecCommand("SelectAll", false, null);
-                                return true;
-                            case Keys.C:
-                            case Keys.Insert:
-                                string _selText = WebBrowser_GetSelectionText(ref PostBrowser);
-                                if (!string.IsNullOrEmpty(_selText))
-                                {
-                                    try
-                                    {
-                                        Clipboard.SetDataObject(_selText, false, 5, 100);
-                                    }
-                                    catch (Exception ex)
-                                    {
-                                        MessageBox.Show(ex.Message);
-                                    }
-                                }
-                                return true;
                             case Keys.Y:
                                 MultiLineMenuItem.Checked = !MultiLineMenuItem.Checked;
                                 MultiLineMenuItem_Click(null, null);
@@ -8218,6 +8200,24 @@ namespace OpenTween
             if (KeyRes)
             {
                 e.IsInputKey = true;
+                return;
+            }
+
+            if (Enum.IsDefined(typeof(Shortcut), (Shortcut)e.KeyData))
+            {
+                var shortcut = (Shortcut)e.KeyData;
+                switch (shortcut)
+                {
+                    case Shortcut.CtrlA:
+                    case Shortcut.CtrlC:
+                    case Shortcut.CtrlIns:
+                        // 既定の動作を有効にする
+                        return;
+                    default:
+                        // その他のショートカットキーは無効にする
+                        e.IsInputKey = true;
+                        return;
+                }
             }
         }
         public bool TabRename(ref string tabName)