fix the issue of restoring focus(#37)
This commit is contained in:
parent
53c36b7363
commit
f11e5efe80
@ -59,7 +59,7 @@ namespace nana
|
|||||||
private:
|
private:
|
||||||
void _m_move(bool to_left);
|
void _m_move(bool to_left);
|
||||||
bool _m_popup_menu();
|
bool _m_popup_menu();
|
||||||
void _m_total_close();
|
void _m_total_close(bool try_restore);
|
||||||
bool _m_close_menu();
|
bool _m_close_menu();
|
||||||
void _m_unload_menu_window();
|
void _m_unload_menu_window();
|
||||||
std::size_t _m_item_by_pos(const ::nana::point&);
|
std::size_t _m_item_by_pos(const ::nana::point&);
|
||||||
@ -90,6 +90,11 @@ namespace nana
|
|||||||
|
|
||||||
nana::menu *menu;
|
nana::menu *menu;
|
||||||
nana::point mouse_pos;
|
nana::point mouse_pos;
|
||||||
|
|
||||||
|
//The menu will restore the focus of taken window. But the restoring during
|
||||||
|
//key_press and key_release resets the focus to the taken window, it causes
|
||||||
|
//the taken window to receive a key_char which should be received by menubar.
|
||||||
|
bool delay_restore;
|
||||||
}state_;
|
}state_;
|
||||||
};
|
};
|
||||||
}//end namespace menubar
|
}//end namespace menubar
|
||||||
|
@ -8,7 +8,8 @@
|
|||||||
* http://www.boost.org/LICENSE_1_0.txt)
|
* http://www.boost.org/LICENSE_1_0.txt)
|
||||||
*
|
*
|
||||||
* @file: nana/gui/detail/window_manager.cpp
|
* @file: nana/gui/detail/window_manager.cpp
|
||||||
*
|
* @author: Jinhao
|
||||||
|
* @contributors: Katsuhisa Yuasa
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <nana/config.hpp>
|
#include <nana/config.hpp>
|
||||||
@ -875,6 +876,14 @@ namespace detail
|
|||||||
if (!root_has_been_focused)
|
if (!root_has_been_focused)
|
||||||
native_interface::set_focus(root_wd->root);
|
native_interface::set_focus(root_wd->root);
|
||||||
|
|
||||||
|
//A fix by Katsuhisa Yuasa
|
||||||
|
//The menubar token window will be redirected to the prev focus window when the new
|
||||||
|
//focus window is a menubar.
|
||||||
|
//The focus window will be restore to the prev focus which losts the focus becuase of
|
||||||
|
//memberbar.
|
||||||
|
if (wd == wd->root_widget->other.attribute.root->menubar)
|
||||||
|
wd = prev_focus;
|
||||||
|
|
||||||
brock.set_menubar_taken(wd);
|
brock.set_menubar_taken(wd);
|
||||||
}
|
}
|
||||||
return prev_focus;
|
return prev_focus;
|
||||||
|
@ -232,10 +232,10 @@ namespace nana
|
|||||||
_m_popup_menu();
|
_m_popup_menu();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
_m_total_close();
|
_m_total_close(true);
|
||||||
}
|
}
|
||||||
else if(npos == state_.active)
|
else if(npos == state_.active)
|
||||||
_m_total_close();
|
_m_total_close(true);
|
||||||
else
|
else
|
||||||
_m_popup_menu();
|
_m_popup_menu();
|
||||||
|
|
||||||
@ -255,7 +255,7 @@ namespace nana
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
state_.behavior = state_.behavior_none;
|
state_.behavior = state_.behavior_none;
|
||||||
_m_total_close();
|
_m_total_close(true);
|
||||||
_m_draw();
|
_m_draw();
|
||||||
API::lazy_refresh();
|
API::lazy_refresh();
|
||||||
}
|
}
|
||||||
@ -305,15 +305,17 @@ namespace nana
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case keyboard::enter:
|
case keyboard::enter:
|
||||||
|
state_.delay_restore = true;
|
||||||
state_.menu->pick();
|
state_.menu->pick();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if(2 != state_.menu->send_shortkey(arg.key))
|
if(2 != state_.menu->send_shortkey(arg.key))
|
||||||
{
|
{
|
||||||
if(state_.active != npos)
|
if (state_.active != npos)
|
||||||
{
|
{
|
||||||
_m_total_close();
|
state_.delay_restore = true;
|
||||||
if(arg.key == 18) //ALT
|
_m_total_close(false);
|
||||||
|
if (arg.key == 18) //ALT
|
||||||
state_.behavior = state_.behavior_focus;
|
state_.behavior = state_.behavior_focus;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -367,6 +369,12 @@ namespace nana
|
|||||||
_m_draw();
|
_m_draw();
|
||||||
API::lazy_refresh();
|
API::lazy_refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (state_.delay_restore)
|
||||||
|
{
|
||||||
|
API::restore_menubar_taken_window();
|
||||||
|
state_.delay_restore = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void trigger::shortkey(graph_reference graph, const arg_keyboard& arg)
|
void trigger::shortkey(graph_reference graph, const arg_keyboard& arg)
|
||||||
@ -440,13 +448,14 @@ namespace nana
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void trigger::_m_total_close()
|
void trigger::_m_total_close(bool try_restore)
|
||||||
{
|
{
|
||||||
_m_close_menu();
|
_m_close_menu();
|
||||||
state_.menu_active = false;
|
state_.menu_active = false;
|
||||||
state_.behavior = state_.behavior_none;
|
state_.behavior = state_.behavior_none;
|
||||||
|
|
||||||
API::restore_menubar_taken_window();
|
if (try_restore)
|
||||||
|
API::restore_menubar_taken_window();
|
||||||
|
|
||||||
auto pos = API::cursor_position();
|
auto pos = API::cursor_position();
|
||||||
API::calc_window_point(widget_->handle(), pos);
|
API::calc_window_point(widget_->handle(), pos);
|
||||||
@ -471,7 +480,8 @@ namespace nana
|
|||||||
state_.menu = nullptr;
|
state_.menu = nullptr;
|
||||||
if(state_.passive_close)
|
if(state_.passive_close)
|
||||||
{
|
{
|
||||||
_m_total_close();
|
_m_total_close(false);
|
||||||
|
|
||||||
_m_draw();
|
_m_draw();
|
||||||
API::update_window(widget_->handle());
|
API::update_window(widget_->handle());
|
||||||
}
|
}
|
||||||
@ -569,7 +579,13 @@ namespace nana
|
|||||||
|
|
||||||
//struct state_type
|
//struct state_type
|
||||||
trigger::state_type::state_type()
|
trigger::state_type::state_type()
|
||||||
:active(npos), behavior(behavior_none), menu_active(false), passive_close(true), nullify_mouse(false), menu(nullptr)
|
: active(npos),
|
||||||
|
behavior(behavior_none),
|
||||||
|
menu_active(false),
|
||||||
|
passive_close(true),
|
||||||
|
nullify_mouse(false),
|
||||||
|
menu(nullptr),
|
||||||
|
delay_restore(false)
|
||||||
{}
|
{}
|
||||||
//end struct state_type
|
//end struct state_type
|
||||||
//end class trigger
|
//end class trigger
|
||||||
|
Loading…
x
Reference in New Issue
Block a user