Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 12-06-2011, 04: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:

Graal Script 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
  #2  
Old 12-06-2011, 05:22 PM
iBeatz iBeatz is offline
Kavan
iBeatz's Avatar
Join Date: Dec 2010
Location: Northern Ireland, UK
Posts: 154
iBeatz will become famous soon enough
Send a message via Yahoo to iBeatz Send a message via Skype™ to iBeatz
Thanks for the ampersand explanation. I didn't know this was available in GScript.
I wondered what that was for when I was making a menu in C++.
Nice tutorial though.

Edit: Must spread some rep before giving it to you again...
__________________

Intelligence without ambition is like a bird without wings.

Reply With Quote
  #3  
Old 12-06-2011, 08:38 PM
Tricxta Tricxta is offline
The Muffin Man
Tricxta's Avatar
Join Date: Oct 2010
Location: Australia
Posts: 563
Tricxta is a jewel in the roughTricxta is a jewel in the rough
what if you want to assign the button to a key in which the letter doesn't exist in the button text. Eg assigning apple to u
Reply With Quote
  #4  
Old 12-06-2011, 10:07 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by Tricxta View Post
what if you want to assign the button to a key in which the letter doesn't exist in the button text. Eg assigning apple to u
You'd have to do it your own way then. Could also try creating an invisible button with the same functionality, mapped to U.
__________________
Reply With Quote
  #5  
Old 12-06-2011, 11:47 PM
MattKan MattKan is offline
the KattMan
Join Date: Aug 2010
Location: United States
Posts: 1,325
MattKan is a splendid one to beholdMattKan is a splendid one to beholdMattKan is a splendid one to beholdMattKan is a splendid one to beholdMattKan is a splendid one to behold
Send a message via AIM to MattKan Send a message via Skype™ to MattKan
MattKan's Mind: Okay, Gunderak, you're stupid threads aren't helping any- oh wait...
Reply With Quote
  #6  
Old 12-07-2011, 12:27 AM
Fulg0reSama Fulg0reSama is offline
Extrinsical Anomaly
Fulg0reSama's Avatar
Join Date: Sep 2009
Location: Ohio
Posts: 3,049
Fulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant future
Quote:
Originally Posted by MattKan View Post
MattKan's Mind: Okay, Gunderak, you're stupid threads aren't helping any- oh wait...
Weird, this is what i was expecting...

__________________

Careful, thoughts and opinions here scare people.
Reply With Quote
  #7  
Old 12-07-2011, 12:48 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
Quote:
Originally Posted by Tricxta View Post
what if you want to assign the button to a key in which the letter doesn't exist in the button text. Eg assigning apple to u
How will the player know to press U? To me that just comes off as bad design choice. If I really wanted it to be that way I would use:

text = "Apple [&U]";
__________________
Quote:
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 08:14 PM.


Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright (C) 1998-2008 Linux cyberjoueurs All Rights Reserved.