I have written a script that uses a message box to allow the user to decide between three possible actions:
importredefdec_1(m):return'R'+str(int(m.group(1))-1)defadd_1(m):return'R'+str(int(m.group(1))+1)# get cursor positionposition=editor.getCurrentPos()action=notepad.messageBox('Yes = inc ------- NO = dec','Inc or Dec',MESSAGEBOXFLAGS.YESNOCANCEL)ifaction==6:# incrementeditor.rereplace('R([0-9]+)',add_1,re.IGNORECASE,position)elifaction==7:# decrementeditor.rereplace('R([0-9]+)',dec_1,re.IGNORECASE,position)#else cancel
As you can see, because of the way it uses "MESSAGEBOXFLAGS.YESNOCANCEL", it is a bit of a bodge. I noticed in the Enums page of the Wiki that there seems to be support for custom buttons using "MESSAGEBOXFLAGS.DEFBUTTON1", but I can't seem to figure out how it works.
Any help on how to give the buttons custom names would be appreciated.
Irvine
Last edit: Irvine_himself 2014-10-08
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
not sure if I'm too late to answer but in case someone else has the same question,
this is a misunderstanding - the MESSAGEBOXFLAGS.DEFBUTTON1, 2, ... flags define
which button is the default one.
E.g.
notepad.messageBox('some message', 'a title', MESSAGEBOXFLAGS.ABORTRETRYIGNORE)
opens a messagebox with three buttons, ABORT, RETRY and IGNORE. The default button
is ABORT.
If you use
notepad.messageBox('some message', 'a title', MESSAGEBOXFLAGS.ABORTRETRYIGNORE | MESSAGEBOXFLAGS.DEFBUTTON2)
Then the same messagebox appears but the default button is now RETRY.
Cheers
Claudia
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have written a script that uses a message box to allow the user to decide between three possible actions:
As you can see, because of the way it uses "MESSAGEBOXFLAGS.YESNOCANCEL", it is a bit of a bodge. I noticed in the Enums page of the Wiki that there seems to be support for custom buttons using "MESSAGEBOXFLAGS.DEFBUTTON1", but I can't seem to figure out how it works.
Any help on how to give the buttons custom names would be appreciated.
Irvine
Last edit: Irvine_himself 2014-10-08
Hi,
not sure if I'm too late to answer but in case someone else has the same question,
this is a misunderstanding - the MESSAGEBOXFLAGS.DEFBUTTON1, 2, ... flags define
which button is the default one.
E.g.
opens a messagebox with three buttons, ABORT, RETRY and IGNORE. The default button
is ABORT.
If you use
Then the same messagebox appears but the default button is now RETRY.
Cheers
Claudia