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

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1572 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2010-12-30 23:47:36 +00:00
parent 31377629c8
commit 29c0dca669
3 changed files with 10 additions and 7 deletions
+1
View File
@@ -213,6 +213,7 @@ void DataEditor::insert(const String& text, const String& action_name) {
void DataEditor::onLeftDown(wxMouseEvent& ev) {
ev.Skip(); // for focus
SetFocus(); // set focus now, otherwise this happens after the editor handles the event, which dismisses transient popup dialogs
CaptureMouse();
// change selection?
selectField(ev, &ValueEditor::onLeftDown);
+8 -6
View File
@@ -70,8 +70,6 @@ void DropDownList::show(bool in_place, wxPoint pos, RealRect* rect) {
item_size.width + marginW * 2,
item_size.height * count + marginH * 2 + line_count
);
RealSize virtual_size = size;
SetVirtualSize(virtual_size);
// placement
int parent_height = 0;
if (!in_place && viewer) {
@@ -91,6 +89,10 @@ void DropDownList::show(bool in_place, wxPoint pos, RealRect* rect) {
parent_height = -(int)item_size.height - 1;
}
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?
int room_below = wxGetDisplaySize().y - border_size.height - pos.y - parent_height - 50;
int max_height = max(200, room_below);
@@ -102,7 +104,6 @@ void DropDownList::show(bool in_place, wxPoint pos, RealRect* rect) {
SetScrollbar(wxVERTICAL,0,0,0,false);
}
// move & resize
item_size.width = virtual_size.width - marginW * 2;
SetSize(add_diagonal(size, border_size));
Position(pos, wxSize(0, parent_height));
// visible item
@@ -143,9 +144,10 @@ void DropDownList::hide(bool event, bool allow_veto) {
}
void DropDownList::realHide() {
if (!IsShown()) return;
Dismiss();
onHide();
if (IsShown()) Dismiss();
}
void DropDownList::OnDismiss() {
hideSubMenu();
if (parent_menu) {
parent_menu->open_sub_menu = nullptr;
+1 -1
View File
@@ -45,7 +45,7 @@ class DropDownList : public wxPopupTransientWindow {
/// Prepare for showing the list
virtual void onShow() {}
/// Do something after hiding the list
virtual void onHide() {}
virtual void OnDismiss();
inline bool isRoot() { return parent_menu == nullptr; }