[racket] Racket GUI with Xlib

From: Laurent (laurent.orseau at gmail.com)
Date: Tue Nov 27 12:05:33 EST 2012

(cc racket-list, as it can be useful information)

On Tue, Nov 27, 2012 at 5:55 PM, Kieron Hardy <kieron.hardy at gmail.com>wrote:

> Are you trying to show the popup without the frame actually being shown?
> i.e. C-f1 before C-f2
>

No, the frame is already shown when I call C-F1


> Have you tried using queue-callback? i.e. Allow the system to complete
> processing of the key (C-f1) event before having it deal with showing the
> popup?
>

That was a good shot, but unfortunately it doesn't work either.


> Do you have any calls to printf or anything else that requires another
> thread to run?
>

Before I added them, no I did not have anything else than (send f
popup-menu ...)

Laurent


>
> On Nov 27, 2012, at 9:25, Laurent <laurent.orseau at gmail.com> wrote:
>
>
>
> On Tue, Nov 27, 2012 at 3:58 PM, Kieron Hardy <kieron.hardy at gmail.com>wrote:
>
>> Laurent, do you have a bit of code that demonstrates your issue?
>>
>
> Well, it's not easy to show a minimal example, as it (seems to) depends on
> an X event loop processing while grabbing the root window.
>
> But I have something like that:
> [...]
> ; create a new event space and use it for all graphics
> (define gui-eventspace (make-eventspace))
> (current-eventspace gui-eventspace)
> [...]
>
> (define menu2 (new popup-menu% [...])
> (define f (new frame% [label "Frame"]))
> (define cb (new button% [parent f] [label "Menu"]
>     [callback (λ(cb ev)(send f popup-menu menu2 100 150))]))
>
> ; keybindings to run commands
> (add-bindings global-keymap
>  "C-F1" (thunk* (send f popup-menu menu2 100 100))
>  "C-F2" (thunk* (send f show #t)) ; to show the frame after the event loop
> has started
> )
>
> [...]
>
> (run-event-loop)
>
>
> When the program starts, I press Ctrl-F2 to show the frame, and then I can
> press the button to show the popup, several times in a row, and the popup
> menu does work correctly.
> But if I press Ctrl-F1 to show the popup menu by attaching it directly to
> the frame instead of going through the callback, not only does it not show
> up, but after that pressing the button does not work anymore (actually, I
> can press the button and it changes its state, so it's not frozen, but the
> popup menu just does not appear).
>
> I've tried to surround the call inside the first thunk* with a `thread'
> and also with a `(parameterize ([current-eventspace (make-eventspace)])' or
> with the gui-eventspace just in case, but without success.
>
> Laurent
>
>
>
>>
>>
>> On Nov 27, 2012, at 4:09, Laurent <laurent.orseau at gmail.com> wrote:
>>
>> Update:
>> Independently of the server and the keybindings:
>> If I create a frame with a button which callback pops up a menu, it works.
>> If I create a frame and call popup-menu on it directly, it fails (the
>> menu does not appear, and the button above does not show its own menu
>> anymore either, which may mean something about eventspaces being frozen?
>> Although I can still click on another button that hides the frame)
>>
>> Any idea? I'm kind of stuck in the eventspace...
>>
>> Laurent
>>
>>
>> On Mon, Nov 26, 2012 at 4:55 PM, Laurent <laurent.orseau at gmail.com>wrote:
>>
>>> There is a remaining problem: I can show frames and buttons alright, and
>>> press them, but popup-menus seem to resist (although the frame I call
>>> show-popup-menu on does show up).
>>>
>>> What's strange is that they work when called from the console (in a
>>> different thread, in a different namespace with eval, but with
>>> namespace-anchor), but not via a keybinding (in the main thread, and in the
>>> main namespace), and I could not yet reproduce this behavior in a simpler
>>> setting than in the server thread...
>>>
>>> Is there something special about popup-menus?
>>>
>>> Laurent
>>>
>>>
>>>
>>> On Sun, Nov 25, 2012 at 6:30 PM, Laurent <laurent.orseau at gmail.com>wrote:
>>>
>>>> It works! Thank you very much!
>>>>
>>>
>>>
>> ____________________
>>  Racket Users list:
>>  http://lists.racket-lang.org/users
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20121127/86191f17/attachment.html>

Posted on the users mailing list.