Commit 54a60218 authored by twanvl's avatar twanvl

fixes of transient popup dialogs, still not perfect, but getting there:

* fixed: popup didn't work when editor didn't have focus
* fixed: dimissal by losing focus didn't repaint dropdown arrows
parent de541224
...@@ -213,6 +213,7 @@ void DataEditor::insert(const String& text, const String& action_name) { ...@@ -213,6 +213,7 @@ void DataEditor::insert(const String& text, const String& action_name) {
void DataEditor::onLeftDown(wxMouseEvent& ev) { void DataEditor::onLeftDown(wxMouseEvent& ev) {
ev.Skip(); // for focus ev.Skip(); // for focus
SetFocus(); // set focus now, otherwise this happens after the editor handles the event, which dismisses transient popup dialogs
CaptureMouse(); CaptureMouse();
// change selection? // change selection?
selectField(ev, &ValueEditor::onLeftDown); selectField(ev, &ValueEditor::onLeftDown);
......
...@@ -70,8 +70,6 @@ void DropDownList::show(bool in_place, wxPoint pos, RealRect* rect) { ...@@ -70,8 +70,6 @@ void DropDownList::show(bool in_place, wxPoint pos, RealRect* rect) {
item_size.width + marginW * 2, item_size.width + marginW * 2,
item_size.height * count + marginH * 2 + line_count item_size.height * count + marginH * 2 + line_count
); );
RealSize virtual_size = size;
SetVirtualSize(virtual_size);
// placement // placement
int parent_height = 0; int parent_height = 0;
if (!in_place && viewer) { if (!in_place && viewer) {
...@@ -91,6 +89,10 @@ void DropDownList::show(bool in_place, wxPoint pos, RealRect* rect) { ...@@ -91,6 +89,10 @@ void DropDownList::show(bool in_place, wxPoint pos, RealRect* rect) {
parent_height = -(int)item_size.height - 1; parent_height = -(int)item_size.height - 1;
} }
pos = GetParent()->ClientToScreen(pos); pos = GetParent()->ClientToScreen(pos);
// virtual size = item size
RealSize virtual_size = size;
SetVirtualSize(virtual_size);
item_size.width = virtual_size.width - marginW * 2;
// is there enough room for all items, or do we need a scrollbar? // is there enough room for all items, or do we need a scrollbar?
int room_below = wxGetDisplaySize().y - border_size.height - pos.y - parent_height - 50; int room_below = wxGetDisplaySize().y - border_size.height - pos.y - parent_height - 50;
int max_height = max(200, room_below); int max_height = max(200, room_below);
...@@ -102,7 +104,6 @@ void DropDownList::show(bool in_place, wxPoint pos, RealRect* rect) { ...@@ -102,7 +104,6 @@ void DropDownList::show(bool in_place, wxPoint pos, RealRect* rect) {
SetScrollbar(wxVERTICAL,0,0,0,false); SetScrollbar(wxVERTICAL,0,0,0,false);
} }
// move & resize // move & resize
item_size.width = virtual_size.width - marginW * 2;
SetSize(add_diagonal(size, border_size)); SetSize(add_diagonal(size, border_size));
Position(pos, wxSize(0, parent_height)); Position(pos, wxSize(0, parent_height));
// visible item // visible item
...@@ -143,9 +144,10 @@ void DropDownList::hide(bool event, bool allow_veto) { ...@@ -143,9 +144,10 @@ void DropDownList::hide(bool event, bool allow_veto) {
} }
void DropDownList::realHide() { void DropDownList::realHide() {
if (!IsShown()) return; if (IsShown()) Dismiss();
Dismiss(); }
onHide();
void DropDownList::OnDismiss() {
hideSubMenu(); hideSubMenu();
if (parent_menu) { if (parent_menu) {
parent_menu->open_sub_menu = nullptr; parent_menu->open_sub_menu = nullptr;
......
...@@ -45,7 +45,7 @@ class DropDownList : public wxPopupTransientWindow { ...@@ -45,7 +45,7 @@ class DropDownList : public wxPopupTransientWindow {
/// Prepare for showing the list /// Prepare for showing the list
virtual void onShow() {} virtual void onShow() {}
/// Do something after hiding the list /// Do something after hiding the list
virtual void onHide() {} virtual void OnDismiss();
inline bool isRoot() { return parent_menu == nullptr; } inline bool isRoot() { return parent_menu == nullptr; }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment