public inbox for guile-gtk@sourceware.org
 help / color / mirror / Atom feed
From: Stephen Tell <tell@cs.unc.edu>
To: Marius Vollmer <mvo@zagadka.ping.de>
Cc: "Greg J. Badros" <gjb@cs.washington.edu>,
	guile-gtk@sourceware.cygnus.com
Subject: Re: Right mouse click on buttons?
Date: Sun, 05 Dec 1999 07:48:00 -0000	[thread overview]
Message-ID: <Pine.GHP.4.10.9912051035420.2043-100000@rukbat.cs.unc.edu> (raw)
In-Reply-To: <874sdxhdop.fsf@zagadka.ping.de>

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

      reply	other threads:[~1999-12-05  7:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-12-04 19:06 Greg J. Badros
1999-12-05  5:04 ` Marius Vollmer
1999-12-05  7:48   ` Stephen Tell [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.GHP.4.10.9912051035420.2043-100000@rukbat.cs.unc.edu \
    --to=tell@cs.unc.edu \
    --cc=gjb@cs.washington.edu \
    --cc=guile-gtk@sourceware.cygnus.com \
    --cc=mvo@zagadka.ping.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).