From 8ca888b063b3f88fc1b55ced75afcfb08b739ecd Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Mon, 16 May 2016 23:26:04 +0200 Subject: [PATCH] Don't focus menus with focusFirstChild() and focusLastChild() --- ChangeLog | 1 + src/fmenu.cpp | 5 +++-- src/fterm.cpp | 2 +- src/fwidget.cpp | 13 ++++++++++--- src/fwidget.h | 6 ++++++ 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index f98b4da8..1382b6c9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ 2016-05-16 Markus Gans * Improve adjustSize() * Implement adjustSizeGlobal() for all widgets + * Don't focus menus with focusFirstChild() and focusLastChild() 2016-05-01 Markus Gans * Better terminal identification diff --git a/src/fmenu.cpp b/src/fmenu.cpp index e03b1047..2af8bb97 100644 --- a/src/fmenu.cpp +++ b/src/fmenu.cpp @@ -93,7 +93,7 @@ void FMenu::init(FWidget* parent) xmin = 1 + rootObj->getLeftPadding(); ymin = 1 + rootObj->getTopPadding(); xmax = rootObj->getWidth(); - ymax = rootObj->getHeight(); + ymax = rootObj->getHeight(); width = 10; height = 2; client_xmin = 1; @@ -107,7 +107,8 @@ void FMenu::init(FWidget* parent) createArea (vwin); setGeometry (1, 1 , 10, 2, false); // initialize geometry values setTransparentShadow(); - window_object = true; + window_object = true; + menu_object = true; addWindow(this); hide(); diff --git a/src/fterm.cpp b/src/fterm.cpp index 24533bec..9f4e4739 100644 --- a/src/fterm.cpp +++ b/src/fterm.cpp @@ -306,7 +306,7 @@ void FTerm::identifyTermType() { type = name = 0; // 0 == not found p = str; - + while ( *p ) { if ( isspace(uChar(*p)) ) diff --git a/src/fwidget.cpp b/src/fwidget.cpp index 7dc4b890..d361f5c0 100644 --- a/src/fwidget.cpp +++ b/src/fwidget.cpp @@ -54,6 +54,7 @@ FWidget::FWidget (FWidget* parent) , adjustWidgetSizeGlobalShadow() , ignore_padding(false) , window_object(false) + , menu_object(false) , flags(0) , foregroundColor() , backgroundColor() @@ -1408,7 +1409,10 @@ bool FWidget::focusFirstChild (void) while ( iter != end ) { FWidget* widget = static_cast(*iter); - if ( widget->isEnabled() && widget->acceptFocus() ) + + if ( widget->isEnabled() + && widget->acceptFocus() + && ! widget->isMenu() ) { widget->setFocus(); if ( widget->numOfChildren() >= 1 ) @@ -1445,7 +1449,10 @@ bool FWidget::focusLastChild (void) { --iter; FWidget* widget = static_cast(*iter); - if ( widget->isEnabled() && widget->acceptFocus() ) + + if ( widget->isEnabled() + && widget->acceptFocus() + && ! widget->isMenu() ) { widget->setFocus(); if ( widget->numOfChildren() >= 1 ) @@ -1716,7 +1723,7 @@ void FWidget::getTermGeometry() getTermSize(); closeConsole(); } - + r_obj->width = term->getWidth(); r_obj->height = term->getHeight(); r_obj->xmin = 1; diff --git a/src/fwidget.h b/src/fwidget.h index 76854a29..6158a129 100644 --- a/src/fwidget.h +++ b/src/fwidget.h @@ -246,6 +246,7 @@ class FWidget : public FObject, public FTerm FRect adjustWidgetSizeGlobalShadow; bool ignore_padding; bool window_object; + bool menu_object; int flags; short foregroundColor; short backgroundColor; @@ -329,6 +330,7 @@ class FWidget : public FObject, public FTerm FWidget* parentWidget() const; bool isRootWidget() const; bool isWindow() const; + bool isMenu() const; virtual bool close(); static FStatusBar* statusBar(); @@ -577,6 +579,10 @@ inline bool FWidget::isShown() const inline bool FWidget::isWindow() const { return window_object; } +//---------------------------------------------------------------------- +inline bool FWidget::isMenu() const +{ return menu_object; } + //---------------------------------------------------------------------- inline bool FWidget::isEnabled() const { return enable; }