input widgets keep focus when form/panel is clicked
see API::ignore_mouse_focus
This commit is contained in:
parent
e7c9708b4f
commit
aac94e238b
@ -21,7 +21,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace nana{
|
namespace nana{
|
||||||
class widget; //declaration ofr nana/widgets/widget.hpp
|
class widget; //declaration of nana/widgets/widget.hpp
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
struct basic_window;
|
struct basic_window;
|
||||||
@ -165,9 +165,10 @@ namespace detail
|
|||||||
bool dropable :1; //Whether the window has make mouse_drop event.
|
bool dropable :1; //Whether the window has make mouse_drop event.
|
||||||
bool fullscreen :1; //When the window is maximizing whether it fit for fullscreen.
|
bool fullscreen :1; //When the window is maximizing whether it fit for fullscreen.
|
||||||
bool borderless :1;
|
bool borderless :1;
|
||||||
bool make_bground_declared : 1; //explicitly make bground for bground effects
|
bool make_bground_declared : 1; //explicitly make bground for bground effects
|
||||||
bool ignore_menubar_focus : 1; //A flag indicates whether the menubar sets the focus.
|
bool ignore_menubar_focus : 1; //A flag indicates whether the menubar sets the focus.
|
||||||
unsigned Reserved :20;
|
bool ignore_mouse_focus : 1; //A flag indicates whether the widget accepts focus when clicking on it
|
||||||
|
unsigned Reserved :19;
|
||||||
unsigned char tab; //indicate a window that can receive the keyboard TAB
|
unsigned char tab; //indicate a window that can receive the keyboard TAB
|
||||||
mouse_action action;
|
mouse_action action;
|
||||||
}flags;
|
}flags;
|
||||||
|
@ -300,6 +300,9 @@ namespace API
|
|||||||
|
|
||||||
nana::mouse_action mouse_action(window);
|
nana::mouse_action mouse_action(window);
|
||||||
nana::element_state element_state(window);
|
nana::element_state element_state(window);
|
||||||
|
|
||||||
|
bool ignore_mouse_focus(window, bool ignore); ///< Enables/disables the mouse focus, it returns the previous state
|
||||||
|
bool ignore_mouse_focus(window); ///< Determines whether the mouse focus is enabled
|
||||||
}//end namespace API
|
}//end namespace API
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
|
||||||
|
@ -346,8 +346,9 @@ namespace nana
|
|||||||
flags.refreshing = false;
|
flags.refreshing = false;
|
||||||
flags.destroying = false;
|
flags.destroying = false;
|
||||||
flags.borderless = false;
|
flags.borderless = false;
|
||||||
flags.make_bground_declared = false;
|
flags.make_bground_declared = false;
|
||||||
flags.ignore_menubar_focus = false;
|
flags.ignore_menubar_focus = false;
|
||||||
|
flags.ignore_mouse_focus = false;
|
||||||
|
|
||||||
visible = false;
|
visible = false;
|
||||||
|
|
||||||
|
@ -1027,12 +1027,19 @@ namespace detail
|
|||||||
{
|
{
|
||||||
arg_keyboard argkey;
|
arg_keyboard argkey;
|
||||||
brock.get_key_state(argkey);
|
brock.get_key_state(argkey);
|
||||||
auto the_next = brock.wd_manager.tabstop(msgwnd, !argkey.shift);
|
auto tstop_wd = brock.wd_manager.tabstop(msgwnd, argkey.shift);
|
||||||
if(the_next)
|
while (tstop_wd)
|
||||||
{
|
{
|
||||||
brock.wd_manager.set_focus(the_next, false);
|
if (!tstop_wd->flags.ignore_mouse_focus)
|
||||||
brock.wd_manager.do_lazy_refresh(the_next, true);
|
{
|
||||||
root_runtime->condition.tabstop_focus_changed = true;
|
brock.wd_manager.set_focus(tstop_wd, false);
|
||||||
|
brock.wd_manager.do_lazy_refresh(msgwnd, false);
|
||||||
|
brock.wd_manager.do_lazy_refresh(tstop_wd, true);
|
||||||
|
root_runtime->condition.tabstop_focus_changed = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
tstop_wd = brock.wd_manager.tabstop(tstop_wd, is_forward);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(keyboard::alt == keychar)
|
else if(keyboard::alt == keychar)
|
||||||
|
@ -935,7 +935,7 @@ namespace detail
|
|||||||
{
|
{
|
||||||
pressed_wd = msgwnd;
|
pressed_wd = msgwnd;
|
||||||
auto new_focus = (msgwnd->flags.take_active ? msgwnd : msgwnd->other.active_window);
|
auto new_focus = (msgwnd->flags.take_active ? msgwnd : msgwnd->other.active_window);
|
||||||
if(new_focus)
|
if(new_focus && (!new_focus->flags.ignore_mouse_focus))
|
||||||
{
|
{
|
||||||
auto kill_focus = brock.wd_manager.set_focus(new_focus, false);
|
auto kill_focus = brock.wd_manager.set_focus(new_focus, false);
|
||||||
if(kill_focus != new_focus)
|
if(kill_focus != new_focus)
|
||||||
@ -1393,13 +1393,21 @@ namespace detail
|
|||||||
{
|
{
|
||||||
if((wParam == 9) && (false == (msgwnd->flags.tab & tab_type::eating))) //Tab
|
if((wParam == 9) && (false == (msgwnd->flags.tab & tab_type::eating))) //Tab
|
||||||
{
|
{
|
||||||
auto the_next = brock.wd_manager.tabstop(msgwnd, (::GetKeyState(VK_SHIFT) >= 0));
|
bool is_forward = (::GetKeyState(VK_SHIFT) >= 0);
|
||||||
if(the_next)
|
|
||||||
|
auto tstop_wd = brock.wd_manager.tabstop(msgwnd, is_forward);
|
||||||
|
while (tstop_wd)
|
||||||
{
|
{
|
||||||
brock.wd_manager.set_focus(the_next, false);
|
if (!tstop_wd->flags.ignore_mouse_focus)
|
||||||
brock.wd_manager.do_lazy_refresh(msgwnd, false);
|
{
|
||||||
brock.wd_manager.do_lazy_refresh(the_next, true);
|
brock.wd_manager.set_focus(tstop_wd, false);
|
||||||
root_runtime->condition.tabstop_focus_changed = true;
|
brock.wd_manager.do_lazy_refresh(msgwnd, false);
|
||||||
|
brock.wd_manager.do_lazy_refresh(tstop_wd, true);
|
||||||
|
root_runtime->condition.tabstop_focus_changed = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
tstop_wd = brock.wd_manager.tabstop(tstop_wd, is_forward);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1037,7 +1037,7 @@ namespace detail
|
|||||||
{
|
{
|
||||||
++i;
|
++i;
|
||||||
core_window_t* ts = (i != end ? (*i) : tabs.front());
|
core_window_t* ts = (i != end ? (*i) : tabs.front());
|
||||||
return (ts != wd ? ts : 0);
|
return (ts != wd ? ts : nullptr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return tabs.front();
|
return tabs.front();
|
||||||
|
@ -1284,5 +1284,25 @@ namespace API
|
|||||||
}
|
}
|
||||||
return nana::element_state::normal;
|
return nana::element_state::normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ignore_mouse_focus(window wd, bool ignore)
|
||||||
|
{
|
||||||
|
auto iwd = reinterpret_cast<restrict::core_window_t*>(wd);
|
||||||
|
internal_scope_guard lock;
|
||||||
|
if (restrict::window_manager.available(iwd))
|
||||||
|
{
|
||||||
|
auto state = iwd->flags.ignore_mouse_focus;
|
||||||
|
iwd->flags.ignore_mouse_focus = ignore;
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ignore_mouse_focus(window wd)
|
||||||
|
{
|
||||||
|
auto iwd = reinterpret_cast<restrict::core_window_t*>(wd);
|
||||||
|
internal_scope_guard lock;
|
||||||
|
return (restrict::window_manager.available(iwd) ? iwd->flags.ignore_mouse_focus : false);
|
||||||
|
}
|
||||||
}//end namespace API
|
}//end namespace API
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
@ -18,9 +18,10 @@ namespace nana
|
|||||||
namespace form
|
namespace form
|
||||||
{
|
{
|
||||||
//class trigger
|
//class trigger
|
||||||
void trigger::attached(widget_reference widget, graph_reference graph)
|
void trigger::attached(widget_reference wdg, graph_reference graph)
|
||||||
{
|
{
|
||||||
wd_ = &widget;
|
wd_ = &wdg;
|
||||||
|
API::ignore_mouse_focus(wdg, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void trigger::refresh(graph_reference graph)
|
void trigger::refresh(graph_reference graph)
|
||||||
|
@ -20,10 +20,13 @@ namespace nana
|
|||||||
namespace panel
|
namespace panel
|
||||||
{
|
{
|
||||||
//class drawer
|
//class drawer
|
||||||
void drawer::attached(widget_reference widget, graph_reference)
|
void drawer::attached(widget_reference wdg, graph_reference)
|
||||||
{
|
{
|
||||||
widget.caption(STR("Nana Panel"));
|
wdg.caption(STR("panel widget"));
|
||||||
window_ = widget.handle();
|
window_ = wdg.handle();
|
||||||
|
|
||||||
|
API::ignore_mouse_focus(wdg, true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawer::refresh(graph_reference graph)
|
void drawer::refresh(graph_reference graph)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user