[haiku-commits] haiku: hrev50156 - in src: apps/webpositive kits/interface

  • From: jscipione@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 18 Mar 2016 01:55:58 +0100 (CET)

hrev50156 adds 1 changeset to branch 'master'
old head: 3c1bde87b6f45def4a5872cb470816e288d4d517
new head: b001655640a3c6ad8d2bbbd2a125dfd52a2bd01f
overview: 
http://cgit.haiku-os.org/haiku/log/?qt=range&q=b001655640a3+%5E3c1bde87b6f4

----------------------------------------------------------------------------

b001655640a3: BWindow & WebPostive: Move TextView detection code
  
  ... from WebPositive to BWindow. This way every window will detect
  Command+Arrows and send them to BTextView if a BTextView has focus
  instead of just WebPositive.
  
  
https://www.freelists.org/post/haiku-development/Wordwise-jumping-with-CTRL-in-BTextView
  
  This trick doesn't work in Vision though...
  
  Fixes #9913

                                     [ John Scipione <jscipione@xxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev50156
Commit:      b001655640a3c6ad8d2bbbd2a125dfd52a2bd01f
URL:         http://cgit.haiku-os.org/haiku/commit/?id=b001655640a3
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Thu Mar 17 23:12:44 2016 UTC

Ticket:      https://dev.haiku-os.org/ticket/9913

----------------------------------------------------------------------------

2 files changed, 12 insertions(+), 15 deletions(-)
src/apps/webpositive/BrowserWindow.cpp | 16 +---------------
src/kits/interface/Window.cpp          | 11 +++++++++++

----------------------------------------------------------------------------

diff --git a/src/apps/webpositive/BrowserWindow.cpp 
b/src/apps/webpositive/BrowserWindow.cpp
index 4f0afdd..389327b 100644
--- a/src/apps/webpositive/BrowserWindow.cpp
+++ b/src/apps/webpositive/BrowserWindow.cpp
@@ -707,21 +707,7 @@ BrowserWindow::DispatchMessage(BMessage* message, 
BHandler* target)
        if ((message->what == B_KEY_DOWN || message->what == 
B_UNMAPPED_KEY_DOWN)
                && message->FindString("bytes", &bytes) == B_OK
                && message->FindInt32("modifiers", &modifierKeys) == B_OK) {
-               modifierKeys = (int32)((uint32)modifierKeys & kModifiers);
-               BTextView* textView = dynamic_cast<BTextView*>(CurrentFocus());
-               if (bytes[0] == B_LEFT_ARROW && modifierKeys == B_COMMAND_KEY) {
-                       if (textView != NULL)
-                               textView->KeyDown(bytes, modifierKeys);
-                       else
-                               PostMessage(GO_BACK);
-                       return;
-               } else if (bytes[0] == B_RIGHT_ARROW && modifierKeys == 
B_COMMAND_KEY) {
-                       if (textView != NULL)
-                               textView->KeyDown(bytes, modifierKeys);
-                       else
-                               PostMessage(GO_FORWARD);
-                       return;
-               } else if (bytes[0] == B_FUNCTION_KEY) {
+               if (bytes[0] == B_FUNCTION_KEY) {
                        // Some function key Firefox compatibility
                        int32 key;
                        if (message->FindInt32("key", &key) == B_OK) {
diff --git a/src/kits/interface/Window.cpp b/src/kits/interface/Window.cpp
index c1abc1b..4be291a 100644
--- a/src/kits/interface/Window.cpp
+++ b/src/kits/interface/Window.cpp
@@ -3803,6 +3803,17 @@ BWindow::_HandleKeyDown(BMessage* event)
                        return true;
                }
 
+               // Send Command+Left and Command+Right to textview if it has 
focus
+               if (key == B_LEFT_ARROW || key == B_RIGHT_ARROW) {
+                       // check key before doing expensive dynamic_cast
+                       BTextView* textView = 
dynamic_cast<BTextView*>(CurrentFocus());
+                       if (textView != NULL) {
+                               textView->KeyDown(bytes, modifiers);
+                               // eat the event
+                               return true;
+                       }
+               }
+
                // Pretend that the user opened a menu, to give the subclass a
                // chance to update it's menus. This may install new shortcuts,
                // which is why we have to call it here, before trying to find


Other related posts: