* The app_server now gives top-most menus the keyboard focus.

* BMenuWindow now makes its menu focus view, so that it can receive key events.
* Keyboard navigation doesn't work as it should though, that is bug #670 is
  still valid - there should even be another recently opened bug about this,
  but Trac obviously ate it :-/


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19152 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2006-10-30 14:21:28 +00:00
parent 3f2cb12385
commit 07dc2c6972
3 changed files with 22 additions and 4 deletions

View File

@ -55,6 +55,7 @@ BMenuWindow::AttachMenu(BMenu *menu)
if (menu != NULL) {
BMenuFrame *menuFrame = new BMenuFrame(menu);
AddChild(menuFrame);
menu->MakeFocus(true);
}
}

View File

@ -100,12 +100,9 @@ KeyboardFilter::_UpdateFocus(int32 key, EventTarget** _target)
if (!fDesktop->LockSingleWindow())
return;
EventTarget* focus = fDesktop->KeyboardEventTarget();
bigtime_t now = system_time();
EventTarget* focus = NULL;
if (fDesktop->FocusWindow() != NULL)
focus = &fDesktop->FocusWindow()->EventTarget();
// TODO: this is a try to not steal focus from the current window
// in case you enter some text and a window pops up you haven't
// triggered yourself (like a pop-up window in your browser while
@ -1074,6 +1071,25 @@ Desktop::_UpdateFronts(bool updateFloating)
}
/*!
Returns the current keyboard event target candidate - which is either the
top-most window (in case it's a menu), or the one having focus.
The window lock must be held when calling this function.
*/
EventTarget*
Desktop::KeyboardEventTarget()
{
WindowLayer* window = _CurrentWindows().LastWindow();
if (window != NULL && window->Feel() == kMenuWindowFeel)
return &window->EventTarget();
if (FocusWindow() != NULL)
return &FocusWindow()->EventTarget();
return NULL;
}
bool
Desktop::_WindowHasModal(WindowLayer* window)
{

View File

@ -144,6 +144,7 @@ class Desktop : public MessageLooper, public ScreenOwner {
int32 ViewUnderMouse(const WindowLayer* window);
void SetFocusWindow(WindowLayer* window);
EventTarget* KeyboardEventTarget();
WindowLayer* FindWindowLayerByClientToken(int32 token, team_id teamID);
//WindowLayer* FindWindowLayerByServerToken(int32 token);