public inbox for guile-gtk@sourceware.org
 help / color / mirror / Atom feed
* Right mouse click on buttons?
@ 1999-12-04 19:06 Greg J. Badros
  1999-12-05  5:04 ` Marius Vollmer
  0 siblings, 1 reply; 3+ messages in thread
From: Greg J. Badros @ 1999-12-04 19:06 UTC (permalink / raw)
  To: guile-gtk

Anybody know how to make GTk+ generate a signal on a right-mouse
click on a button (or a button-bar)?  "clicked" seems to only be
generated by a left-click.  Same for "pressed" and "released".

Better, anybody do context-sensitive popup menus w/ guile-gtk?

Thanks,
Greg

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Right mouse click on buttons?
  1999-12-04 19:06 Right mouse click on buttons? Greg J. Badros
@ 1999-12-05  5:04 ` Marius Vollmer
  1999-12-05  7:48   ` Stephen Tell
  0 siblings, 1 reply; 3+ messages in thread
From: Marius Vollmer @ 1999-12-05  5:04 UTC (permalink / raw)
  To: Greg J. Badros; +Cc: guile-gtk

"Greg J. Badros" <gjb@cs.washington.edu> writes:

> Anybody know how to make GTk+ generate a signal on a right-mouse
> click on a button (or a button-bar)?

Try the "button_press_event" signal, like so

    (use-modules (gtk gtk)
                 (gtk gdk))

    (let ((w (gtk-window-new 'toplevel))
          (b (gtk-button-new-with-label "Click Me Right!")))
      (gtk-container-add w b)
      (gtk-signal-connect b "button_press_event" 
                          (lambda (ev)
                            (cond
                             ((= (gdk-event-button ev) 3)
                              (display "Yes!\n")
                              #t)
                             (else
                              #f))))
      (gtk-widget-show-all w)
      (gtk-standalone-main w))

- Marius

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Right mouse click on buttons?
  1999-12-05  5:04 ` Marius Vollmer
@ 1999-12-05  7:48   ` Stephen Tell
  0 siblings, 0 replies; 3+ messages in thread
From: Stephen Tell @ 1999-12-05  7:48 UTC (permalink / raw)
  To: Marius Vollmer; +Cc: Greg J. Badros, guile-gtk

On 5 Dec 1999, Marius Vollmer wrote:

> "Greg J. Badros" <gjb@cs.washington.edu> writes:
> 
> > Anybody know how to make GTk+ generate a signal on a right-mouse
> > click on a button (or a button-bar)?
 
> Try the "button_press_event" signal, like so

>       (gtk-signal-connect b "button_press_event" 
>                           (lambda (ev)
 
For a context-sensitive popup menu out of such an event, build the menu in
the event handler, and use gtk-menu-popup. In this code, I put the actual
gtk-signal-connect in C, which calls out to guile on selected events and
passes along a context object. The menu actions are specific to my
program, but you get the idea I'm sure.
   I've done this for a drawing_area - does the menu pop up in the
correct-looking place when attached to a button?



(wavepanel-bind-mouse 3   ; calls proc on indicated button-press event
 (lambda (wp event)
   (let ((menu (gtk-menu-new)))
     (gtk-widget-show menu)
     (add-menuitem menu "Zoom Cursors" x-zoom-cursors!)
     (add-menuitem menu "Zoom Area..." x-zoom-area!)
     (add-menuitem menu "Zoom Full" x-zoom-full!)
     (case (wavepanel-type wp)
       ((0) (add-menuitem menu "Set type jge"
                          (lambda () (set-wavepanel-type! wp 1))))
       ((1) (add-menuitem menu "Set type std"
                          (lambda () (set-wavepanel-type! wp 0)))))
     (gtk-menu-popup menu #f #f
                     (gdk-event-button event)
                     (gdk-event-time event)))))


; add-menuitem is a little helper to make menu and menubar creation
; a bit more readable.
(define-public (add-menuitem parent label proc)
  (let ((item (if label
                  (gtk-menu-item-new-with-label label)
                  (gtk-menu-item-new))))
    (gtk-widget-show item)
    (if proc
        (gtk-signal-connect item "activate" proc))
    (cond ((gtk-menu? parent) (gtk-menu-append parent item))
          ((gtk-menu-bar? parent) (gtk-menu-bar-append parent item)))
    item))


-- 
Steve Tell | tell@cs.unc.edu | http://www.cs.unc.edu/~tell | KF4ZPF
Research Associate, Microelectronic Systems Laboratory
Computer Science Department, UNC@Chapel Hill.   W:919-962-1845

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1999-12-05  7:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-12-04 19:06 Right mouse click on buttons? Greg J. Badros
1999-12-05  5:04 ` Marius Vollmer
1999-12-05  7:48   ` Stephen Tell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).