From c21873f063c9ded00e04b06423e9fbfa64545f0d Mon Sep 17 00:00:00 2001 From: John Scipione Date: Sat, 11 Jan 2014 23:22:40 -0500 Subject: [PATCH] WebPositive: BTextView shortcuts work in URL bar Pass Cmd+Left/Right to the BTextView base class if the URL bar is focused. This allows us to make use of the navigation shortcuts in BTextView when we are focused on the URL bar, and activates back and forward navigation otherwise. Unfortunately this doesn't also work for text fields inside webpages. Also make modifierKeys signed. --- src/apps/webpositive/BrowserWindow.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/apps/webpositive/BrowserWindow.cpp b/src/apps/webpositive/BrowserWindow.cpp index 4dc0559dfa..843e4935c2 100644 --- a/src/apps/webpositive/BrowserWindow.cpp +++ b/src/apps/webpositive/BrowserWindow.cpp @@ -646,17 +646,23 @@ void BrowserWindow::DispatchMessage(BMessage* message, BHandler* target) { const char* bytes; - uint32 modifierKeys; + int32 modifierKeys; if ((message->what == B_KEY_DOWN || message->what == B_UNMAPPED_KEY_DOWN) && message->FindString("bytes", &bytes) == B_OK - && message->FindInt32("modifiers", (int32*)&modifierKeys) == B_OK) { - - modifierKeys = modifierKeys & 0x000000ff; + && message->FindInt32("modifiers", &modifierKeys) == B_OK) { + modifierKeys = (int32)((uint32)modifierKeys & 0x000000ff); + BTextView* textView = dynamic_cast(CurrentFocus()); if (bytes[0] == B_LEFT_ARROW && modifierKeys == B_COMMAND_KEY) { - PostMessage(GO_BACK); + if (textView != NULL) + textView->KeyDown(bytes, modifierKeys); + else + PostMessage(GO_BACK); return; } else if (bytes[0] == B_RIGHT_ARROW && modifierKeys == B_COMMAND_KEY) { - PostMessage(GO_FORWARD); + if (textView != NULL) + textView->KeyDown(bytes, modifierKeys); + else + PostMessage(GO_FORWARD); return; } else if (bytes[0] == B_FUNCTION_KEY) { // Some function key Firefox compatibility