unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Miguel Frasson <frasson@altair.math.leidenuniv.nl>,
	Emacs-Devel <emacs-devel@gnu.org>
Subject: Re: pop-up tool-bar
Date: Thu, 07 Oct 2004 16:07:59 -0400	[thread overview]
Message-ID: <jwvhdp6qp4h.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <FDELKNEBLPKKDCEBEJCBOECPCIAA.drew.adams@oracle.com> (Drew Adams's message of "Thu, 7 Oct 2004 12:01:01 -0700")

> The mouse-up event is two events removed from the event that triggers
> command show-tool-bar-for-one-command: 1) click Tool Bar, 2) mouse-down, 3)
> mouse-up. The Tool Bar click shows, then hides, the tool-bar, but the hiding
> doesn't take place until the mouse-down.

It looks like the problem is that the event you get from read-event is not
"valid" any more after you remove the toolbar (becaue the position is
changed).

Using read-event is generally a source a trouble.  But the alternatives
aren't great either.  Maybe you can try something like the appended code.

Note: you should pay attention to the case where the frame has been deleted
by the next command.

Also, you declare your minor mode to be ":global t" but it is frame-local,
so you should add (make-variable-frame-local 'tool-bar-here-mode) somewhere
at the toplevel.


        Stefan


(defun add-hook-once (hook function append local)
  "Same as `add-hook', but FUN is only run once.
Also contrary to `add-hook', this is not idempotent."
  (let ((code (list 'lambda)))
    (setcdr code `(() (,function) (remove-hook ',hook ',code ',local)))
    (add-hook hook code append local)))

...

(defun show-tool-bar-for-one-command ()
  "Pop up the tool bar so you can click a button.
The tool bar stays visible until one command is executed
\(whether or not it was initiated by clicking a button)."
  (interactive)
  (tool-bar-here-mode 1)
  (add-hook-once 'post-command-hook
                 `(lambda ()
                    ;; We're just now done with show-tool-bar-for-one-command.
                    (add-hook-once 'post-command-hook
                                   (lambda ()
                                     ;; We're done with the next command.
                                     (select-frame ',(selected-frame))
                                     (tool--bar-here-mode -1))))))

  reply	other threads:[~2004-10-07 20:07 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-07  7:51 pop-up tool-bar Drew Adams
2004-10-07 11:33 ` Miguel Frasson
2004-10-07 19:01   ` Drew Adams
2004-10-07 20:07     ` Stefan Monnier [this message]
2004-10-07 21:04       ` Drew Adams
2004-10-07 21:44         ` Drew Adams
2004-10-09 15:44           ` Richard Stallman
2004-10-10 19:15             ` Drew Adams
2004-10-08 17:20         ` Drew Adams
2004-10-08 17:39           ` Stefan
2004-10-08 18:24             ` David Kastrup
2004-10-08 19:58               ` Drew Adams
2004-10-08 19:03             ` Drew Adams
2004-10-08 23:12               ` Stefan Monnier
2004-10-09  0:46                 ` Drew Adams
2004-10-11  4:45           ` Drew Adams
2004-10-07 20:08     ` David Kastrup
2004-10-07 20:20       ` Drew Adams
2004-10-07 20:54         ` Stefan Monnier
2004-10-07 20:56         ` David Kastrup
2004-10-08  6:12     ` Miguel Frasson
2004-10-09 15:45       ` Richard Stallman
2004-10-07 15:13 ` Stefan Monnier
2004-10-07 17:15   ` Drew Adams

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=jwvhdp6qp4h.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=frasson@altair.math.leidenuniv.nl \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).