Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   onKeyDown() and keydown(i) in GUIControls (https://forums.graalonline.com/forums/showthread.php?t=134262583)

AlexanderK 03-27-2011 10:56 PM

onKeyDown() and keydown(i) in GUIControls
 
I'm modifying my inventory to work with the keyboard, but I'm running into some problems
Why doesn't this work?
PHP Code:

function onMenuKeyDown() {
   
player.chat="MenuKeyDown";
   if (
keydown(8)) {
     
player.chat="TAB";
     
Inventory_Categories.forceonaction();
  }


The player only chats "MenuKeyDown".

So I'm doing this instead,which works, but can I even use keycodes? Aren't they platform specific?
PHP Code:

function onMenuKeyDown(gui,keycode) {
   
player.chat="MenuKeyDown";
   if (
keycode==9) {
     
player.chat="TAB";
     
Inventory_Categories.forceonaction();
  }



Crow 03-27-2011 10:59 PM

Quote:

Originally Posted by Fulg0reSama (Post 1639489)
Just a silly guess

PHP Code:

function onMenuKeyDown(gui,keycode) {
   
player.chat="MenuKeyDown";
}
   if (
keycode==9) {
     
player.chat="TAB";
     
Inventory_Categories.forceonaction();
  }


You forgot a bracket I believe.

:oo:

Fulg0reSama 03-27-2011 11:03 PM

Quote:

Originally Posted by Crow (Post 1639490)
:oo:

Yeah, I didn't see GUIControls in the title...

Just forget I said anything.

xAndrewx 03-27-2011 11:07 PM

wild guess

GraalControl GUI (Which Graal is...) only has the keydown features. You're doing your system wrong if you need to do something like that. Can't you use this:

HTML Code:

function onKeyPressed() {
  if (keydown(0)) this.s_pos = max(0, this.s_pos- 10);
  if (keydown(1)) this.s_pos = max(0, this.s_pos - 1);
  if (keydown(2)) this.s_pos = max(0, this.s_pos + 10);
  if (keydown(3)) this.s_pos = max(0, this.s_pos + 1);
}

Would work I suppose if you had 10 items displayed on each row. Think about it?

AlexanderK 03-27-2011 11:10 PM

Quote:

Originally Posted by xAndrewx (Post 1639498)
wild guess

GraalControl GUI (Which Graal is...) only has the keydown features.

It really seems that way. The moment GraalControl isn't the first Responder, keydown() doesn't work.

So can I use keycodes or scancodes for special keys like TAB or SPACE? Will they be the same for Windows, Linux and Mac?

xAndrewx 03-27-2011 11:11 PM

Quote:

Originally Posted by AlexanderK (Post 1639503)
It really seems that way. The moment GraalControl isn't the first Responder, keydown() doesn't work.

So can I use keycodes or scancodes for special keys like TAB or SPACE? Will they be the same for Windows, Linux and Mac?

I don't think so. Refer to origional post ^^

fowlplay4 03-27-2011 11:27 PM

Script help for 'key*global':

Clientside:
keydown2global(int, bool) - returns boolean
keydownglobal(int) - returns boolean

Script help for 'mouse*global':
Clientside:
leftmousebuttonglobal - boolean (read only)
middlemousebuttonglobal - boolean (read only)
mousebuttonsglobal - integer (read only)
rightmousebuttonglobal - boolean (read only)

AlexanderK 03-27-2011 11:30 PM

Quote:

Originally Posted by fowlplay4 (Post 1639512)
Script help for 'key*global':

Clientside:
keydown2global(int, bool) - returns boolean
keydownglobal(int) - returns boolean

Script help for 'mouse*global':
Clientside:
leftmousebuttonglobal - boolean (read only)
middlemousebuttonglobal - boolean (read only)
mousebuttonsglobal - integer (read only)
rightmousebuttonglobal - boolean (read only)

I love you right now.

xAndrewx 03-27-2011 11:30 PM

oh cooool


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

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