[racket] Racket GUI with Xlib

From: Laurent (laurent.orseau at gmail.com)
Date: Tue Nov 27 11:52:09 EST 2012

On Tue, Nov 27, 2012 at 5:43 PM, Robby Findler
<robby at eecs.northwestern.edu>wrote:

> Is the callback than handles the c-f1 keystroke running in
> gui-eventspace or in some other eventspace?
>

It's in the gui-eventspace (just checked with a printf and a comparison
with `(eq? (current-eventspace) gui-eventspace)'), and so is the button
callback.



>
> Robby
>
> On Tue, Nov 27, 2012 at 10:25 AM, 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
> >
> >
> >
> > ____________________
> >   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/7217b8f6/attachment-0001.html>

Posted on the users mailing list.