vanilla icon indicating copy to clipboard operation
vanilla copied to clipboard

revamping vanilla dialogs

Open typemytype opened this issue 4 years ago • 4 comments

for now only askYesNo and askYesNoCancel are available

https://github.com/robotools/vanilla/blob/master/Lib/vanilla/dialogs.py

typemytype avatar Feb 16 '21 14:02 typemytype

Im in favour of adding def ask(...) which is the most generic method askYesNo is a bit more specific.

ask(
    "message",
    "info",
    altertStyle="critical",
    buttons=[dict(title="Yes", callback=yesCallback), dict("Nooooooooooo", callback=nooooooooCallback) ]
)

also add:

both the alert style as the button titles should be backward compatible

typemytype avatar Feb 16 '21 15:02 typemytype

Yes, love this.

benkiel avatar Feb 16 '21 21:02 benkiel

A couple of things on ask:

  1. Should the displayed buttons follow the order of the items in the button title list?

If my button titles are:

buttonTitles=[
    dict(title="A", returnCode=1),
    dict(title="B", returnCode=2),
    dict(title="C", returnCode=3),
    dict(title="D", returnCode=4),
    dict(title="E", returnCode=5)
],

They will be shown to the user as [E D C B A]. Maybe it's logical? It confused me at first.

  1. I'd like to be able to control the default button and add a key command.
  • default : True | False (False is the default)
  • keyCommand : Same structure as Button.bind

These are discussed in the addButtonWithTitle documentation.

I can write this code. I just want to make sure it's an okay idea.

typesupply avatar Feb 24 '21 18:02 typesupply

  1. The order is keept as it was before this changes, which is indeed reversed.

  2. The Default button is just the first one... when a button has "Cancel" as title it will have a key equivalent of esc, same for "Don't Save" with cmd-D see https://developer.apple.com/documentation/appkit/nsalert/1532992-buttons?language=objc

having an optional "default" and "keyCommand" would be super useful!

addButtonWithTitle returns the NSButton object which can be used to change the its behaviour

I already added "callback" as option, which is called when the button is hit

typemytype avatar Feb 24 '21 23:02 typemytype

Can we close this?

typesupply avatar Dec 20 '23 17:12 typesupply

Yes.

benkiel avatar Dec 20 '23 21:12 benkiel