• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Any way to assign hotkeys to dialog buttons?

Status
Not open for further replies.
Level 8
Joined
Jul 17, 2004
Messages
283
I saw in a custom map called The World RPG, for their teleporter to go to different areas, a dialog appears, and for each dialog button, they have [1] for the first one, [2] for the second one, [3] for the third one, etc. So you can press 1, 2, 3, etc, depending on which one you wanted. How do you do that?

Or is it like that by default? The dialog's default hotkeys are 1, 2, 3, etc in order..?
 
You can specify dialog hotkeys through JASS.

For example, if you have some Dialog "DialogVariable", you can add a button like so:
  • Custom script: set bj_lastCreatedButton = DialogAddButton(udg_DialogVariable, "Dialog Button Text", '1')
  • // perform actions for this button using (last created button)
  • Custom script: set bj_lastCreatedButton = DialogAddButton(udg_DialogVariable, "Dialog Button Text", '2')
  • // perform actions for this button using (last created button)
  • Custom script: set bj_lastCreatedButton = DialogAddButton(udg_DialogVariable, "Dialog Button Text", '3')
  • // etc..
The third field specifies the dialog's hotkey. Note that it is placed in single quotes 'X'. If you want it to be a letter, simply use a letter within the quotes instead, such as 'A' (it won't restrict it to uppercase).

You can also put a number, but it is easier to just enclose it in quotes. There are also special hotkeys, where you would just use the numbers directly. Taken from my dialog wrapper:
JASS:
/**************************************************
*
*   Constants - Credits to DysfunctionaI for the list!
*/
    globals
        constant integer KEY_SPACEBAR          = 32
        
        /* Number Pad */
        constant integer KEY_NUMPAD_0          = 257
        constant integer KEY_NUMPAD_1          = 258
        constant integer KEY_NUMPAD_2          = 259
        constant integer KEY_NUMPAD_3          = 260
        constant integer KEY_NUMPAD_4          = 261
        constant integer KEY_NUMPAD_5          = 262
        constant integer KEY_NUMPAD_6          = 263
        constant integer KEY_NUMPAD_7          = 264
        constant integer KEY_NUMPAD_8          = 265
        constant integer KEY_NUMPAD_9          = 266
        constant integer KEY_NUMPAD_PLUS       = 267
        constant integer KEY_NUMPAD_MINUS      = 268
        constant integer KEY_NUMPAD_ASTERISK   = 269 
        constant integer KEY_NUMPAD_SLASH      = 270
        constant integer KEY_NUMPAD_PERIOD     = 271
        
        constant integer KEY_EQUALS            = 272
        constant integer KEY_MINUS             = 273
        constant integer KEY_LEFT_BRACKET      = 274
        constant integer KEY_RIGHT_BRACKET     = 275
        constant integer KEY_BACKSLASH         = 276
        constant integer KEY_SEMICOLON         = 277
        constant integer KEY_APOSTROPHE        = 278
        constant integer KEY_COMMA             = 279
        constant integer KEY_PERIOD            = 280   
        constant integer KEY_SLASH             = 281
        constant integer KEY_ESCAPE            = 512
        constant integer KEY_BACKSPACE         = 514
        
        /* Arrows */
        constant integer KEY_LEFT_ARROW        = 516
        constant integer KEY_UP_ARROW          = 517
        constant integer KEY_RIGHT_ARROW       = 518
        constant integer KEY_DOWN_ARROW        = 519
        
        constant integer KEY_INSERT            = 520
        constant integer KEY_DELETE            = 521
        constant integer KEY_HOME              = 522
        constant integer KEY_END               = 523
        constant integer KEY_PAGE_UP           = 524
        constant integer KEY_PAGE_DOWN         = 525
        constant integer KEY_CAPS_LOCK         = 526
        constant integer KEY_NUM_LOCK          = 527
        constant integer KEY_SCROLL_LOCK       = 528
        constant integer KEY_PAUSE             = 529
        
        /* Function Buttons */
        constant integer KEY_F1                = 768
        constant integer KEY_F2                = 769
        constant integer KEY_F3                = 770
        constant integer KEY_F4                = 771
        constant integer KEY_F5                = 772
        constant integer KEY_F6                = 773
        constant integer KEY_F7                = 774
        constant integer KEY_F8                = 775
        constant integer KEY_F9                = 776
        constant integer KEY_F10               = 777
        constant integer KEY_F11               = 778
        constant integer KEY_F12               = 779
    endglobals
/*
**************************************************/
 
Level 8
Joined
Jul 17, 2004
Messages
283
Mr. PurgeandFire, do I just reference the dialog buttons like this?

  • (Clicked dialog button) Equal to Dialog_Button[1]
With this...

  • Dialog - Change the title of Dialog to Teleport to:
  • Custom script: set bj_lastCreatedButton = DialogAddButton(udg_Dialog, "[1] The Forest", '1')
  • Set Dialog_Button[1] = (Last created dialog Button)
  • Custom script: set bj_lastCreatedButton = DialogAddButton(udg_Dialog, "[2] Undoing Ruin", '2')
  • Set Dialog_Button[2] = (Last created dialog Button)
  • Dialog - Show Dialog for Player 1 (Red)
 
Status
Not open for further replies.
Top