Discussion:
Creating a modeless pop-up from a modal parent?
The Devils Jester
17 years ago
Permalink
I have been trying to implement a custom "pop-up" of sorts (its more
closely related to a combo box pop-up) however I have run into two
separate problems.

1. If I have the popup as a modal wxFrame, then the wxActivateEvent
is not called when the pop-up is deactivated (i.e. the user clicks
somewhere other than the popup).

2. If I have the popup as a modeless wxFrame, then it never gets
input focus because its parent is modal.

Is there a solution to either of these, or should I be using something
else to implement the pop-up?

I noticed a dialog called wxPopupWindow, but it doesnt seem to support
all of my targets (GTK2, MSW, MAC).
--
If you make something that any idiot can use, only idiots will use it.
Vadim Zeitlin
17 years ago
Permalink
On Sat, 11 Oct 2008 14:10:42 -0400 The Devils Jester <***@gmail.com> wrote:

TDJ> Is there a solution to either of these, or should I be using something
TDJ> else to implement the pop-up?

Yes, you should use wxPopupWindow.

TDJ> I noticed a dialog called wxPopupWindow, but it doesnt seem to support
TDJ> all of my targets (GTK2, MSW, MAC).

I believe it does work under all of these platforms because
wxOwnerDrawnComboBox uses it and it works there AFAIK.

Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
The Devils Jester
17 years ago
Permalink
Post by Vadim Zeitlin
I believe it does work under all of these platforms because
wxOwnerDrawnComboBox uses it and it works there AFAIK.
Are you certain? Julian says that its not (which is his reason for
not having it in DialogBlocks), and a quick grep of the latest
wxWidgets source code provides numerous notes about needing to
implement it on various platforms (MSW and Mac mainly). Of course I
havent browsed the code deeply enough to actually know for certain
either way.

That being said, I will look into it a little further, I really need
this to work, however if I could get my existing implementation to
work without having to use/learn a new object especially one that isnt
supported in DialogBlocks, that would be even better. If
wxPopupWindow manages this, then there is some trick to it, is it
possible to make a wxFrame do the same thing?
...
--
If you make something that any idiot can use, only idiots will use it.
Vadim Zeitlin
17 years ago
Permalink
On Sat, 11 Oct 2008 19:56:41 -0400 The Devils Jester <***@gmail.com> wrote:

TDJ> > I believe it does work under all of these platforms because
TDJ> > wxOwnerDrawnComboBox uses it and it works there AFAIK.
TDJ>
TDJ> Are you certain?

I'm certain it works under wxMSW and I'm almost certain it works under Mac
in the svn trunk. I'm not quite sure about wxMac/2.8 combination.

TDJ> If wxPopupWindow manages this, then there is some trick to it, is it
TDJ> possible to make a wxFrame do the same thing?

Not really, otherwise we wouldn't need wxPopupWindow.

Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
Jaakko Salli
17 years ago
Permalink
Post by Vadim Zeitlin
TDJ> > I believe it does work under all of these platforms because
TDJ> > wxOwnerDrawnComboBox uses it and it works there AFAIK.
TDJ>
TDJ> Are you certain?
I'm certain it works under wxMSW and I'm almost certain it works under Mac
in the svn trunk. I'm not quite sure about wxMac/2.8 combination.
TDJ> If wxPopupWindow manages this, then there is some trick to it, is it
TDJ> possible to make a wxFrame do the same thing?
Not really, otherwise we wouldn't need wxPopupWindow.
Either way, in wxComboCtrl code, there is still option to fall back to
use wxDialog as a replacement for missing or dysfunctional
wxPopupWindow. Quick scan would indicate that none of the three major
platforms need this anymore. Still, I wonder if, instead of having this
fall back code in wxComboCtrl, maybe it would make more sense to create
generic wxDialog-based wxPopupWindow for platforms that do not yet have
native implementation.

Jaakko
Vadim Zeitlin
17 years ago
Permalink
On Sun, 12 Oct 2008 16:01:10 +0300 Jaakko Salli <***@pp.inet.fi> wrote:

JS> Either way, in wxComboCtrl code, there is still option to fall back to
JS> use wxDialog as a replacement for missing or dysfunctional
JS> wxPopupWindow. Quick scan would indicate that none of the three major
JS> platforms need this anymore. Still, I wonder if, instead of having this
JS> fall back code in wxComboCtrl, maybe it would make more sense to create
JS> generic wxDialog-based wxPopupWindow for platforms that do not yet have
JS> native implementation.

It definitely would make more sense to do this than do it in wxComboCtrl
code (i.e. I think this workaround/fallback should be removed from
wxComboCtrl). Whether it would make sense is another question though as I'm
not sure if there are any platforms at all where a normal wxTLW can be used
as a wxPopupWindow. So IMO such fallback won't work correctly anywhere. But
there is no harm in having it neither and I could be wrong.

So, to summarize, I definitely think the option to use wxDialog instead
of wxPopupWindow should be removed from wxComboCtrl. If you feel motivated
enough to move the code into a generic wxPopupWindow implementation, please
feel free to do it. But if not, just removing it from wxComboCtrl is IMO
still better than keeping it there.

Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
The Devils Jester
17 years ago
Permalink
I dont quite understand. If we have established that the wxDialog is
not capable of this functionality, then what is the point in having it
as a fall back? A sieve as a fall back in case my cup breaks?
...
--
If you make something that any idiot can use, only idiots will use it.
Vadim Zeitlin
17 years ago
Permalink
On Sun, 12 Oct 2008 09:16:50 -0400 The Devils Jester <***@gmail.com> wrote:

TDJ> I dont quite understand. If we have established that the wxDialog is
TDJ> not capable of this functionality, then what is the point in having it
TDJ> as a fall back?

It's not a good replacement for wxPopupWindow on any of the currently
supported major platforms (nor wxMotif AFAIK). It might be a better
replacement (than nothing at all) on some other platform. As I said, I
don't believe it's actually going to happen but I could be wrong.

Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
The Devils Jester
17 years ago
Permalink
Ok, well here is my question then.

So far, in all my hundred or so dialogs, I have had DialogBlocks to
generate the bare bones structure and events for each of my dialogs,
and I am not yet experianced enough with the wxWidgets 'concept'.

I can (and will if no one answers) stumble around until I manage to
get a decent bare bones, but if anyone has, or can quickly write me up
a wxPopupWindow example that does nothing except show a small, empty
window, that would speed things along. If not, its understandable, I
will manage.
...
--
If you make something that any idiot can use, only idiots will use it.
Vadim Zeitlin
17 years ago
Permalink
On Sun, 12 Oct 2008 09:27:04 -0400 The Devils Jester <***@gmail.com> wrote:

TDJ> I can (and will if no one answers) stumble around until I manage to
TDJ> get a decent bare bones, but if anyone has, or can quickly write me up
TDJ> a wxPopupWindow example that does nothing except show a small, empty
TDJ> window, that would speed things along.

Have a look at samples/popup.

Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
Jaakko Salli
17 years ago
Permalink
Post by The Devils Jester
I dont quite understand. If we have established that the wxDialog is
not capable of this functionality, then what is the point in having it
as a fall back? A sieve as a fall back in case my cup breaks?
It could work as a fall back - with caveats. In other words, much
support code was needed, some of which I'm not sure could be integrated
in a generic wxPopupWindow.

Jaakko
The Devils Jester
17 years ago
Permalink
The only issue I am having with a simple modal wxFrame as a popup, is
there is no way to determine if you 'clicked away' from it. If there
was, I would have no need for wxPopupWindow at all. When I make it
non modal, so I can get these messages, I have other problems.

If I can manage to cobble together a basic wxPopupWindow test, or
someone happens to have one laying about, then I will try this instead
of my current method.
...
--
If you make something that any idiot can use, only idiots will use it.
Vadim Zeitlin
17 years ago
Permalink
On Sun, 12 Oct 2008 09:45:14 -0400 The Devils Jester <***@gmail.com> wrote:

TDJ> The only issue I am having with a simple modal wxFrame as a popup, is
TDJ> there is no way to determine if you 'clicked away' from it.

The activation is all wrong (at least under MSW) when using wxFrame as
popup.

Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
Jaakko Salli
17 years ago
Permalink
Post by The Devils Jester
The only issue I am having with a simple modal wxFrame as a popup, is
there is no way to determine if you 'clicked away' from it. If there
was, I would have no need for wxPopupWindow at all. When I make it
non modal, so I can get these messages, I have other problems.
Yes, this is problem too in generic wxDialog usage in wxComboCtrl, and
it sometimes, for this behavior to be perfect, or at least near so, some
extra code has to be added in containing control (for example,
wxPropertyGrid, which uses wxOwnerDrawnComboBox extensively). However,
IIRC, common portion of wxPopupWindow code uses mouse capture to resolve
this issue, and I think this should work for wxDialog as well as
specialty platform-specific popup windows.

Jaakko
Jaakko Salli
17 years ago
Permalink
...
I agree that it probably won't work well on general level, but doing
this would still reduce much of conditional code in wxComboCtrl. I think
on some occasions, there would still have to be wxIsKindOf(wnd,
CLASSINFO(wxDialog)) checks.
Post by Vadim Zeitlin
So, to summarize, I definitely think the option to use wxDialog instead
of wxPopupWindow should be removed from wxComboCtrl. If you feel motivated
enough to move the code into a generic wxPopupWindow implementation, please
feel free to do it. But if not, just removing it from wxComboCtrl is IMO
still better than keeping it there.
Just removing the code will then obviously prevent wxComboCtrl from
functioning when wxPopupWindow is not present. Anyway, I'll look into it.

Oh, and BTW, in my experience wxComboCtrl did work surprisingly well
even if popup window was simply just a wxDialog.

Jaakko
Jaakko Salli
17 years ago
Permalink
If you feel motivated enough to move the code into a generic wxPopupWindow implementation, please
feel free to do it. But if not, just removing it from wxComboCtrl is IMO
still better than keeping it there.
With a closer look, I see now that there is member function wxComboCtrl
::UseAltPopupWindow() to allow explicit use of wxDialog'ish window as
popup, in case more reliable focus and child control handling is
required. So, I ended up to not removing wxDialog support / fall-back.

Also, if include/wx/popupwin.h is to be believed, nowadays there should
be working (at some degree, at least) wxPopupWindow implementation for
basically all supported platforms, so I guess it would be pretty moot to
create a generic implementation.

Jaakko

Loading...