Hi Augie,
I have spoken to one of the developers and here is the info that he
passed on:
The problem is that PtFontSelection() is a modal function. It does not
return until you have closed the font selector.
While waiting for you to push the OK button, PtFontSelection() runs its
own event processing loop to make sure that any events that arrive in
the meantime get processed correctly. If one of those events triggers a
callback that ends up calling PtFontSelection() again, the second
PtFontSelection() call will enter another event loop. And you will be
stuck in that loop until you click on the second dialog’s OK button –
it’s a general and pretty obvious rule that if function A calls function
B, there’s no way for function A to return before function B has
returned.
Since the first PtFontSelection() call can’t return before the second
one, one shouldn’t be surprised why clicking on the first font
selector’s OK dialog doesn’t change the font. It’s another thing
whether it should at least close the font selector dialog. Personally,
I don’t think it really matters, since either way the behaviour will
feel wrong. I think I prefer the way it behaves right now because it
makes it more obvious that there’s something wrong with your application
– closing the dialog without applying the change might sometimes be
more difficult to notice when you’re testing your app.
The lesson is: multiple modal functions are nested. The only way to
prevent that is by having multiple threads running PtMainLoop() – but
that’s not something you could do in Photon 1.14. The proper solution,
even in QNX 6, is to avoid modal functions. Instead of calling
PtFontSelection(), it’s better to just open a dialog and return to main
loop, and let callbacks attached to the dialog do the rest of the work.
Hope this helps
Regards
Brenda
Augie Henriques wrote:
Hi,
Assume we have two PtText widgets (A & B) and that we can bring up two
windows simultaneously (one for each widget) to change the properties of
each widget.
So we have two edit windows open at a time (A & B). Each window ‘belongs’
to a different PtText widget (A & B).
One of the items we have in the windows is a button to change the font. So
when the user clicks in this button, we call PtFontSelection.
We can get the two edit windows (A & B) each with a PtFontSelection dialog
open.
So if we click on window A font button we get a PtFontSelection dialog for
A. Then we click on window B font button and we get a PtFontSelection
dialog for B.
If we go to the PtFontSelection dialog for A and select and font and click
on done, the dialog stays open until we click on the done button for dialog
B. Then we get both callbacks at the same time and both dialog windows are
destroyed.
Why? Is this not possible?
We are trying to create general purpose modules to change the Font and
Color, that we can call over and over again from all kinds of different
places. We would like these to be multi instance non-blocking
(dialog/windows).
Is there any source code how to do this?
TIA
Augie