The GUI objects are great for creating nice and easy GUIs that are navigate-able by mouse but it doesn't hurt to put in the extra effort to make them accessible by keyboard as well.
If anyone else has any other tips that are listed below feel free to post them, the main purpose of this post was to shed light on an small undocumented section of GS2.
1. Keyboard Shortcuts
For buttons you can make them more 'keyboard accessible' by placing an ampersand (&) before the letter you want it to be made the shortcut key. In Graal just pressing the letter will trigger the shortcut compared to other applications where you have to hold alt and the key.
Example:
PHP Code:
//#CLIENTSIDE
function onCreated() {
// Create Button with 'X' as Shortcut Key
new GuiButtonCtrl("ExitButton") {
x = y = 100;
width = height = 100;
text = "E&xit";
}
}
function ExitButton.onAction() {
// Destroys Button
// Depending on the GUI toggle visibility instead
ExitButton.destroy();
// Set Focus Back to Window/Graal
GraalControl.makefirstresponder(true);
}
There's also keyDown, keyUp and other events for controls so you can add custom functionality that way as well.
2. Set focus to the most appropriate control after an event
There isn't a
control.setfocus() function for objects but you can accomplish roughly the same effect by using
control.makefirstresponder(true);
When you open a window set focus to the most important control they're going to use. I.e: In Zodiac's skill menu it's the skill list control.
Also when you close a window make sure you set focus back to GraalControl (or even the previous window they were on) otherwise it may glitch and require the player to click the screen before they can move again.