From 6c6e9cdb1aadcb69a522c71a046147049ac432e4 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Tue, 14 Jul 2009 22:42:15 +0000 Subject: [PATCH] Rework copy message dispatching to auto-dispatch to the focus view rather than targetting the textview specifically. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31571 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../debugger/gui/team_window/SourceView.cpp | 32 ++++++----- .../debugger/gui/team_window/SourceView.h | 1 - .../debugger/gui/team_window/TeamWindow.cpp | 55 +++++++++++-------- 3 files changed, 50 insertions(+), 38 deletions(-) diff --git a/src/apps/debugger/gui/team_window/SourceView.cpp b/src/apps/debugger/gui/team_window/SourceView.cpp index fc18fcbdff..872cdfa744 100644 --- a/src/apps/debugger/gui/team_window/SourceView.cpp +++ b/src/apps/debugger/gui/team_window/SourceView.cpp @@ -213,6 +213,7 @@ public: virtual void KeyDown(const char* bytes, int32 numBytes); virtual void MakeFocus(bool isFocused); + virtual void MessageReceived(BMessage* message); virtual void MouseDown(BPoint where); virtual void MouseMoved(BPoint where, uint32 transit, const BMessage* dragMessage); @@ -947,6 +948,22 @@ SourceView::TextView::MakeFocus(bool isFocused) } +void +SourceView::TextView::MessageReceived(BMessage* message) +{ + switch (message->what) + { + case B_COPY: + CopySelectionToClipboard(); + break; + + default: + SourceView::BaseView::MessageReceived(message); + break; + } +} + + void SourceView::TextView::MouseDown(BPoint where) { @@ -1337,21 +1354,6 @@ SourceView::TargetedByScrollView(BScrollView* scrollView) } -void -SourceView::MessageReceived(BMessage* message) -{ - switch (message->what) - { - case B_COPY: - fTextView->CopySelectionToClipboard(); - break; - - default: - BView::MessageReceived(message); - break; - } -} - BSize SourceView::MinSize() { diff --git a/src/apps/debugger/gui/team_window/SourceView.h b/src/apps/debugger/gui/team_window/SourceView.h index e7ab23c85b..6c55a7592e 100644 --- a/src/apps/debugger/gui/team_window/SourceView.h +++ b/src/apps/debugger/gui/team_window/SourceView.h @@ -45,7 +45,6 @@ public: void HighlightBorder(bool state); virtual void TargetedByScrollView(BScrollView* scrollView); - virtual void MessageReceived(BMessage *message); virtual BSize MinSize(); virtual BSize MaxSize(); diff --git a/src/apps/debugger/gui/team_window/TeamWindow.cpp b/src/apps/debugger/gui/team_window/TeamWindow.cpp index 3885115e8e..f75cf0d8eb 100644 --- a/src/apps/debugger/gui/team_window/TeamWindow.cpp +++ b/src/apps/debugger/gui/team_window/TeamWindow.cpp @@ -117,29 +117,40 @@ void TeamWindow::DispatchMessage(BMessage* message, BHandler* handler) { // Handle function key shortcuts for stepping - if (fActiveThread != NULL && message->what == B_KEY_DOWN) { - int32 key; - uint32 modifiers; - if (message->FindInt32("key", &key) == B_OK - && message->FindInt32("modifiers", (int32*)&modifiers) == B_OK) { - switch (key) { - case B_F10_KEY: - fListener->ThreadActionRequested(this, fActiveThread->ID(), - MSG_THREAD_STEP_OVER); - break; - case B_F11_KEY: - if ((modifiers & B_SHIFT_KEY) != 0) { - fListener->ThreadActionRequested(this, - fActiveThread->ID(), MSG_THREAD_STEP_OUT); - } else { - fListener->ThreadActionRequested(this, - fActiveThread->ID(), MSG_THREAD_STEP_INTO); + switch (message->what) { + case B_KEY_DOWN: + if (fActiveThread != NULL) { + int32 key; + uint32 modifiers; + if (message->FindInt32("key", &key) == B_OK + && message->FindInt32("modifiers", (int32*)&modifiers) + == B_OK) { + switch (key) { + case B_F10_KEY: + fListener->ThreadActionRequested(this, + fActiveThread->ID(), MSG_THREAD_STEP_OVER); + break; + case B_F11_KEY: + if ((modifiers & B_SHIFT_KEY) != 0) { + fListener->ThreadActionRequested(this, + fActiveThread->ID(), MSG_THREAD_STEP_OUT); + } else { + fListener->ThreadActionRequested(this, + fActiveThread->ID(), MSG_THREAD_STEP_INTO); + } + break; + default: + break; } - break; - default: - break; + } } - } + break; + + case B_COPY: + BView* focusView = CurrentFocus(); + if (focusView != NULL) + focusView->MessageReceived(message); + break; } BWindow::DispatchMessage(message, handler); } @@ -401,7 +412,7 @@ TeamWindow::_Init() fMenuBar->AddItem(menu); item = new BMenuItem("Copy", new BMessage(B_COPY), 'C'); menu->AddItem(item); - item->SetTarget(fSourceView); + item->SetTarget(this); AutoLocker locker(fDebugModel); _UpdateRunButtons();