Gnus development mailing list
 help / color / mirror / Atom feed
* Switching window for buttons
@ 1998-10-12 21:18 Hrvoje Niksic
  1998-10-18  1:12 ` William Perry
  0 siblings, 1 reply; 2+ messages in thread
From: Hrvoje Niksic @ 1998-10-12 21:18 UTC (permalink / raw)


I agree with whoever observed that it is obnoxious for the widget
buttons to switch to the window when pressing the button.  I've never
noticed it before because I've mostly used widget buttons with
Customize, where this is not a big problem.  This patch should fix it
for XEmacs.

Please don't apply the patch until wmperry confirms that it doesn't
break W3.  The length is due to reindentation.

Note that this patch will not apply to FSF Emacs; I'm not sure if the
same logic can apply there.


1998-10-12  Hrvoje Niksic  <hniksic@srce.hr>

	* wid-edit.el (widget-button-click): Don't switch window.

--- lisp/wid-edit.el.orig	Sun Aug 23 12:37:45 1998
+++ lisp/wid-edit.el	Mon Oct 12 23:13:23 1998
@@ -1063,48 +1063,49 @@
 
 (defun widget-button-click (event)
   "Invoke button below mouse pointer."
-  (interactive "@e")
-  (cond ((event-glyph event)
-	 (widget-glyph-click event))
-	((widget-event-point event)
-	 (let* ((pos (widget-event-point event))
-		(button (get-char-property pos 'button)))
-	   (if button
-	       (let* ((extent (widget-get button :button-extent))
-		      (face (extent-property extent 'face))
-		      (mouse-face (extent-property extent 'mouse-face))
-		      (help-echo (extent-property extent 'help-echo)))
-		 (unwind-protect
-		     (progn
-		       ;; Merge relevant faces, and make the result mouse-face.
-		       (let ((merge `(widget-button-pressed-face ,mouse-face)))
-			 (nconc merge (if (listp face)
-					  face (list face)))
-			 (setq merge (delete-if-not 'find-face merge))
-			 (set-extent-property extent 'mouse-face merge))
-		       (unless (widget-apply button :mouse-down-action event)
-			 ;; Wait for button release.
-			 (while (not (button-release-event-p
-				      (setq event (next-event))))
-			   (dispatch-event event)))
-		       ;; Disallow mouse-face and help-echo.
-		       (set-extent-property extent 'mouse-face nil)
-		       (set-extent-property extent 'help-echo nil)
-		       (setq pos (widget-event-point event))
-		       (unless (eq (current-buffer) (extent-object extent))
-			 ;; Barf if dispatch-event tripped us by
-			 ;; changing buffer.
-			 (error "Buffer changed during mouse motion"))
-		       ;; Do the associated action.
-		       (when (and pos (extent-in-region-p extent pos pos))
-			 (widget-apply-action button event)))
-		   ;; Unwinding: fully release the button.
-		   (set-extent-property extent 'mouse-face mouse-face)
-		   (set-extent-property extent 'help-echo help-echo)))
-	     ;; This should not happen!
-	     (error "`widget-button-click' called outside button"))))
-	(t
-	 (message "You clicked somewhere weird"))))
+  (interactive "e")
+  (with-current-buffer (event-buffer event)
+    (cond ((event-glyph event)
+	   (widget-glyph-click event))
+	  ((widget-event-point event)
+	   (let* ((pos (widget-event-point event))
+		  (button (get-char-property pos 'button)))
+	     (if button
+		 (let* ((extent (widget-get button :button-extent))
+			(face (extent-property extent 'face))
+			(mouse-face (extent-property extent 'mouse-face))
+			(help-echo (extent-property extent 'help-echo)))
+		   (unwind-protect
+		       (progn
+			 ;; Merge relevant faces, and make the result mouse-face.
+			 (let ((merge `(widget-button-pressed-face ,mouse-face)))
+			   (nconc merge (if (listp face)
+					    face (list face)))
+			   (setq merge (delete-if-not 'find-face merge))
+			   (set-extent-property extent 'mouse-face merge))
+			 (unless (widget-apply button :mouse-down-action event)
+			   ;; Wait for button release.
+			   (while (not (button-release-event-p
+					(setq event (next-event))))
+			     (dispatch-event event)))
+			 ;; Disallow mouse-face and help-echo.
+			 (set-extent-property extent 'mouse-face nil)
+			 (set-extent-property extent 'help-echo nil)
+			 (setq pos (widget-event-point event))
+			 (unless (eq (current-buffer) (extent-object extent))
+			   ;; Barf if dispatch-event tripped us by
+			   ;; changing buffer.
+			   (error "Buffer changed during mouse motion"))
+			 ;; Do the associated action.
+			 (when (and pos (extent-in-region-p extent pos pos))
+			   (widget-apply-action button event)))
+		     ;; Unwinding: fully release the button.
+		     (set-extent-property extent 'mouse-face mouse-face)
+		     (set-extent-property extent 'help-echo help-echo)))
+	       ;; This should not happen!
+	       (error "`widget-button-click' called outside button"))))
+	  (t
+	   (message "You clicked somewhere weird")))))
 
 (defun widget-button1-click (event)
   "Invoke glyph below mouse pointer."


-- 
Hrvoje Niksic <hniksic@srce.hr> | Student at FER Zagreb, Croatia
--------------------------------+--------------------------------
You can only be young once, but you can be immature forever.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Switching window for buttons
  1998-10-12 21:18 Switching window for buttons Hrvoje Niksic
@ 1998-10-18  1:12 ` William Perry
  0 siblings, 0 replies; 2+ messages in thread
From: William Perry @ 1998-10-18  1:12 UTC (permalink / raw)
  Cc: XEmacs Patches, ding

Hrvoje Niksic <hniksic@srce.hr> writes:

> I agree with whoever observed that it is obnoxious for the widget
> buttons to switch to the window when pressing the button.  I've never
> noticed it before because I've mostly used widget buttons with
> Customize, where this is not a big problem.  This patch should fix it
> for XEmacs.
> 
> Please don't apply the patch until wmperry confirms that it doesn't
> break W3.  The length is due to reindentation.

  I see no reason this should break emacs/w3, other than the current window
will be replaced with whatever URL you just clicked on though.  A little
odd.  I haven't actually had a chance to test this though - my w3 time is
ridiculously short. :(

-bill p.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1998-10-18  1:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-10-12 21:18 Switching window for buttons Hrvoje Niksic
1998-10-18  1:12 ` William Perry

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 NNTP newsgroup(s).