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.
This commit is contained in:
John Scipione
2014-01-30 19:48:34 -05:00
parent 741987bed7
commit c21873f063
+12 -6
View File
@@ -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<BTextView*>(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