Discussion:
Adding a button in the tool bar
(too old to reply)
Hibou57 (Yannick Duchêne)
2010-02-19 13:28:20 UTC
Permalink
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
Allan
2010-03-01 01:37:06 UTC
Permalink
Post by Hibou57 (Yannick Duchêne)
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.
You should post in gnu.emacs.help instead.
--
Allan
Loading...