Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > New Scripting Engine (GS2)
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 12-06-2011, 05:39 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Tips for Making GUI's Keyboard Accessible

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") {
    
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.
__________________
Quote:
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 02:05 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.