From cc9f6bbded785a2a4f20e26b74939fd3fc87c856 Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Mon, 27 Dec 2004 14:16:56 +0000 Subject: [PATCH] Implemented RestoreFocus(). Thanks to Ingo and Marc for the help git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10539 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/MenuBar.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/kits/interface/MenuBar.cpp b/src/kits/interface/MenuBar.cpp index 8aa4a8f230..a080a34c87 100644 --- a/src/kits/interface/MenuBar.cpp +++ b/src/kits/interface/MenuBar.cpp @@ -35,6 +35,7 @@ #include #include +#include struct menubar_data { @@ -454,7 +455,16 @@ BMenuBar::RestoreFocus() { BWindow *window = Window(); if (window && window->Lock()) { - // TODO: Give focus back to the previous focus BView + BHandler *handler = NULL; + if (BPrivate::gDefaultTokens.GetToken(fPrevFocusToken, B_HANDLER_TOKEN, + (void **)&handler, NULL) == B_OK) { + BView *view = dynamic_cast(handler); + // TODO: Are there other things to do in case the BHandler + // is not a BView ? + if (view != NULL) + view->MakeFocus(); + } + fPrevFocusToken = NULL; window->Unlock(); } }