2

On OSX, using the following variable/keymap and code snippet, a mouse click on the "SUBMIT" button will generate a system popup confirmation message, whereas an enter key on the "SUBMIT" button will generate a minibuffer confirmation message. Is there setting to control whether the confirmation is requested in the minibuffer versus a system popup?

VARIABLE:   my-widget-keymap

(defvar my-widget-keymap
  (let ((map (make-sparse-keymap)))
    (define-key map [down-mouse-2] 'widget-button-click)
    (define-key map [down-mouse-1] 'widget-button-click)
    (define-key map "\r" 'widget-button-press)
    map)
  "Keymap containing useful binding for buffers containing widgets.")

CODE SNIPPET:

(let ((buffer (get-buffer-create "*TEST*")))
  (with-current-buffer buffer
    (erase-buffer)
    (widget-create 'push-button
               :tag "SUBMIT"
               :format "%[%v%]"
               :keymap my-widget-keymap
               :notify `(lambda (_wid &rest _ignore)
                          (when (y-or-n-p "proceed?")
                            (message "Hello-World!")))))
  (display-buffer buffer t))
Drew
  • 75,699
  • 9
  • 109
  • 225
lawlist
  • 18,826
  • 5
  • 37
  • 118
  • 1
    The doc string for `y-or-no-p` says: `Under a windowing system a dialog box will be used if ‘last-nonmenu-event’ is nil and ‘use-dialog-box’ is non-nil.` So I think you can get the question in the minibuffer even if you click. I'm not sure whether you can get a pop-up with a RET. – NickD Jan 20 '22 at 16:27

1 Answers1

1

As @NickD suggested in a comment, try customizing or binding variable use-dialog-box to nil, to use the keyboard (minibuffer input) to confirm y/n even when you click the push button with the mouse.

(Using keyboard Enter (RET) on the button will always use the minibuffer for (keyboard) confirmation.)

Drew
  • 75,699
  • 9
  • 109
  • 225