Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Adding a button in the tool bar
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Yannick Duchêne Hibou57  
View profile  
 More options Feb 19 2010, 8:28 am
Newsgroups: gnu.emacs
From: Hibou57 (Yannick Duchêne) <yannick_duch...@yahoo.fr>
Date: Fri, 19 Feb 2010 14:28:20 +0100
Local: Fri, Feb 19 2010 8:28 am
Subject: Adding a button in the tool bar

Hello,

I'm new to this newsgroup, and I'm not sure if weither or not it's OK to  
ask for such a question here (should I use gnu.emacs.help instead ?). If  
it's not OK, please, just tell me.

I wanted to add some buttons in the emacs tool bar (well, TBH, I'm  
planning to have some kind of control, to avoid me to have to remember  
about some command hot-keys).

I've tried a little Emacs-Lisp script, which seems to work, but does not  
really works all fine. This indeed adds a button to the tool bar, triggers  
the good command when the button is clicked, but the button also has an  
unexpected behavior : it oftenly disappears sometime when the tool bar is  
refreshed. But not all the time : sometime the tool-bar is refreshed and  
the button remains there.

An example case which can make the button disappear : I move the mouse  
cursor over the button, wait a bit so that the help text appears, then I  
move the cursor somewhere else on the tool-bar, move it slowly over the  
tool-bar... then, oops, the button disappear.

I could not figure what's the issue can be.

Wishing this is not too much long, here is the sample Emacs-Lisp source :

;;; test.el --- Test

;;; Commentary:
;; Dono what to say.

;;; History:
;; Written today.

;;; Code:

(defun print-coucou ()
   "Function which print 'Coucou' in the current buffer."
   "This can be used as a command (marked as interactive)."
   (interactive)
   (print "Coucou!" (current-buffer))
)

(define-key
   global-map       ; The context where the binding applies
   [tool-bar dummy] ; How the binding is triggered
   '(menu-item      ; What is triggered, is a menu item
    "Print Coucou"  ; The name of the menu item
    print-coucou    ; The action associated to the menu item (reference)
    :enable 1
    :visible 1
    :help "Hi! I'm the command help text."
    :image (image :type xpm :file "preferences.xpm")
   )
)

(provide 'test)

;;; test.el ends here

Have a nice day, and happy writing :)

P.S. I'm using Emacs 23.1.1 on Windows XP SP3

--
No-no, this isn't an oops ...or I hope (TM) - Don't blame me... I'm just  
not lucky


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.