From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: pop-up tool-bar Date: Thu, 07 Oct 2004 16:07:59 -0400 Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Message-ID: References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1097179731 21887 80.91.229.6 (7 Oct 2004 20:08:51 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 7 Oct 2004 20:08:51 +0000 (UTC) Cc: Miguel Frasson , Emacs-Devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Oct 07 22:08:37 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1CFeZ3-0004s5-00 for ; Thu, 07 Oct 2004 22:08:37 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CFefo-0004Rc-HG for ged-emacs-devel@m.gmane.org; Thu, 07 Oct 2004 16:15:36 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CFefe-0004R2-S7 for emacs-devel@gnu.org; Thu, 07 Oct 2004 16:15:27 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CFefd-0004QS-FD for emacs-devel@gnu.org; Thu, 07 Oct 2004 16:15:25 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CFefd-0004Ph-5x for emacs-devel@gnu.org; Thu, 07 Oct 2004 16:15:25 -0400 Original-Received: from [132.204.24.67] (helo=mercure.iro.umontreal.ca) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CFeYW-0007oJ-EM for emacs-devel@gnu.org; Thu, 07 Oct 2004 16:08:04 -0400 Original-Received: from hidalgo.iro.umontreal.ca (hidalgo.iro.umontreal.ca [132.204.27.50]) by mercure.iro.umontreal.ca (Postfix) with ESMTP id 1F38C8282A6; Thu, 7 Oct 2004 16:08:04 -0400 (EDT) Original-Received: from asado.iro.umontreal.ca (asado.iro.umontreal.ca [132.204.24.84]) by hidalgo.iro.umontreal.ca (Postfix) with ESMTP id 4E47D4AC078; Thu, 7 Oct 2004 16:08:00 -0400 (EDT) Original-Received: by asado.iro.umontreal.ca (Postfix, from userid 20848) id C89358CA23; Thu, 7 Oct 2004 16:07:59 -0400 (EDT) Original-To: "Drew Adams" In-Reply-To: (Drew Adams's message of "Thu, 7 Oct 2004 12:01:01 -0700") User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3.50 (gnu/linux) X-DIRO-MailScanner-Information: Please contact the ISP for more information X-DIRO-MailScanner: Found to be clean X-DIRO-MailScanner-SpamCheck: n'est pas un polluriel, SpamAssassin (score=0, requis 5) X-MailScanner-From: monnier@iro.umontreal.ca X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:28055 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:28055 > 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))))))