Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   gui and catchevent question (https://forums.graalonline.com/forums/showthread.php?t=134262691)

MrOmega 04-05-2011 12:05 AM

gui and catchevent question
 
In my scrolls I use a textctrl and set it's modal to false so I can get the event from just the scroll behind. textctrl won't return the events when I test it (modal is false) but still does block the scrollctrl preventing me from catching onmousedown

PHP Code:

//Snippet
        
new GuiScrollCtrl"Keyboard_" temp."_" temp.b)
        {

          
useOwnProfile  true;
          
profile        "GuiScrollProfile";
          
profile.border 4;
          
profile.bitmap "guiglife_keyscroll.png";
          
position       = {( temp.== && temp.0)? ( 24 44 temp.b): ( temp.== && temp.0)? ( 40 44 temp.b): ( temp.== && temp.0)? ( 48 44 temp.b): ( 44 temp.b), 44 temp.a};
          
extent         = {( temp.key == ">>")? 64: ( temp.key == "<<")? 64: ( temp.key == "Backspace")? 128: ( temp.key in "Upper""Lower"})? 80:( temp.key == "Enter")? 156:( temp.key == "Shift")? 88:( temp.key == "Space")? 1484040};
          
vscrollBar     hscrollBar "alwaysOff";
          
thiso.catchEventthis"OnMouseDown""KeyboardDown");
        
          new 
GuiTextCtrl"Keyboard_" temp."_" temp."_Text")
          {
          
            
useownProfile        true;
            
position             = { -2, -14};
            
width                = ( "Keyboard_" temp."_" temp.b).width
            
text                 temp.key;
            
profile.fontColor    = { 2552550205};
            
profile.fontSize     24;
            
profile.fontStyle    "cb";
            
profile.fontType     "Arial";
            
profile.shadowOffset = { 22};
            
profile.shadowColor  = { 000};
            
profile.align        "center";
            
profile.textShadow   true;
            
profile.modal        profile.autoSizeWidth false;
            
useOwnProfile        true;
            
          }
        } 


fowlplay4 04-05-2011 12:37 AM

and you have:

PHP Code:

function KeyboardDown(obj) {
  
//defined?


Something about having useownprofile being set last before your profile vars doesn't gel right with me either.

Mark Sir Link 04-05-2011 12:58 AM

the event you're catching is onMouseDown, and invoking
PHP Code:

function KeyboardDown(){



outside of the UI block

should also change this to name or this.name I believe, it is expecting a string, not an object.

fowlplay4 04-05-2011 01:40 AM

Quote:

Originally Posted by Mark Sir Link (Post 1641311)
should also change this to name or this.name I believe, it is expecting a string, not an object.

No it does expect an object, Graal's object/string magic just lets that way work.

Mark Sir Link 04-05-2011 01:42 AM

TGraalVar.catchevent(str, str, str) - adds an event handler for the specified object and event, third parameter is the function which receives the event (first parameter of the event will be the object for which the event occured)

MrOmega 04-05-2011 01:42 AM

@ fowlplay4:
Yes it's defined properly just not echoing anything, removing useownprofile at the end doesn't work either.

@Mark Sir Link:
Chris Vimes instructed me to use 'this'

DustyPorViva 04-05-2011 01:51 AM

Sometimes Graal wants an object, aka "this" sometimes it wants a reference to an object, aka "name." Enjoy the ****ing headaches.

Mark Sir Link 04-05-2011 02:01 AM

I am only going with what scripthelp displays as the expected params, 3 strings

not sure what other string it could possibly want besides name, and I'm sure the reason this works isn't because it's what's expected, but instead because echoing objects tends to return object.name

Anyway, on closer look, I think the real issue here is you are throwing an event for mousedown when I assume that that event is thrown when the scroll buttons are pushed. You have the scroll bars disabled, so I think it would be a virtual impossibility to ever throw that event.

MrOmega 04-05-2011 02:05 AM

Quote:

Originally Posted by Mark Sir Link (Post 1641321)
Anyway, on closer look, I think the real issue here is you are throwing an event for mousedown when I assume that that event is thrown when the scroll buttons are pushed. You have the scroll bars disabled, so I think it would be a virtual impossibility to ever throw that event.

after testing you are correct, thank you.

Deas_Voice 04-06-2011 08:36 PM

Quote:

Originally Posted by Mark Sir Link (Post 1641321)
I am only going with what scripthelp displays as the expected params, 3 strings

not sure what other string it could possibly want besides name, and I'm sure the reason this works isn't because it's what's expected, but instead because echoing objects tends to return object.name

Quote:

Originally Posted by Mark Sir Link (Post 1641317)
TGraalVar.catchevent(str, str, str) - adds an event handler for the specified object and event, third parameter is the function which receives the event (first parameter of the event will be the object for which the event occured)

there's your parameters right there.
it want's an object, documention failure. (<- future reference, i know it have been solved already)

fowlplay4 04-06-2011 08:41 PM

Quote:

Originally Posted by Deas_Voice (Post 1641799)
there's your parameters right there.
it want's an object, documention failure. (<- future reference, i know it have been solved already)

Well it ultimately finds the object (object/string magic still stands) whether you pass it the reference or it's name anyway.

I.e:

PHP Code:

function onCreated() {
  
temp.req requesturl("http://google.ca");
  
temp.requestname temp.req.name;  // Just for example, don't actually do it this way.
  
this.catchevent(temp.requestname"onReceiveData""onWebData");
}

function 
onWebData() {
  echo(
"Data received!");


Passing an object still looks better in the end though.

Mark Sir Link 04-06-2011 09:27 PM

Quote:

Originally Posted by Deas_Voice (Post 1641799)
there's your parameters right there.
it want's an object, documention failure. (<- future reference, i know it have been solved already)

not sure what you're trying to indicate since it reads "specified object" rather than just object.

Specified leads me to believe string even more so.

cbk1994 04-06-2011 09:39 PM

Quote:

Originally Posted by Mark Sir Link (Post 1641809)
not sure what you're trying to indicate since it reads "specified object" rather than just object.

Specified leads me to believe string even more so.

Specified object means exactly that—the specified object. It's the object you want to catch events from. Why does specified make you think string?

You could use the name, but I think it's silly to do so in an object-oriented language. Who knows what it does behind the scenes, though...


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

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