'suffix' is no longer a safe global variable name in scripts;

Drop down list for word lists stay open after clicking on a prefix choice.

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@663 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2007-09-02 18:18:04 +00:00
parent 0157f96f9a
commit 01de02b904
7 changed files with 42 additions and 34 deletions
+16 -2
View File
@@ -66,6 +66,7 @@ DropDownList::DropDownList(Window* parent, bool is_submenu, ValueViewer* viewer)
, viewer(viewer)
, hider (is_submenu ? nullptr : new DropDownHider(*this))
, hider2(is_submenu ? nullptr : new DropDownHider(*this))
, close_on_mouse_out(false)
{
if (is_submenu) {
parent_menu = &dynamic_cast<DropDownList&>(*GetParent());
@@ -148,9 +149,9 @@ void DropDownList::show(bool in_place, wxPoint pos, RealRect* rect) {
void DropDownList::hide(bool event, bool allow_veto) {
// hide?
bool keep_open = event && allow_veto && stayOpen();
bool keep_open = event && allow_veto && stayOpen(selected_item);
if (keep_open) {
Refresh(false);
close_on_mouse_out = true;
} else {
// hide root
DropDownList* root = this;
@@ -162,6 +163,7 @@ void DropDownList::hide(bool event, bool allow_veto) {
// send event
if (event && selected_item != NO_SELECTION && itemEnabled(selected_item)) {
select(selected_item);
if (IsShown()) Refresh(false);
}
}
@@ -343,6 +345,17 @@ void DropDownList::onMotion(wxMouseEvent& ev) {
hideSubMenu();
}
void DropDownList::onMouseLeave(wxMouseEvent& ev) {
if (close_on_mouse_out) {
wxSize cs = GetClientSize();
if (ev.GetX() < 0 || ev.GetY() < 0 || ev.GetX() >= cs.x || ev.GetY() >= cs.y) {
hide(false); // outside box; hide it
ev.Skip();
return;
}
}
}
// ----------------------------------------------------------------------------- : DropDownList : Parent events
bool DropDownList::onMouseInParent(wxMouseEvent& ev, bool open_in_place) {
@@ -429,4 +442,5 @@ BEGIN_EVENT_TABLE(DropDownList,wxPopupWindow)
EVT_LEFT_DOWN (DropDownList::onLeftDown)
EVT_LEFT_UP (DropDownList::onLeftUp)
EVT_MOTION (DropDownList::onMotion)
EVT_LEAVE_WINDOW (DropDownList::onMouseLeave)
END_EVENT_TABLE ()