HeroEngine Forums
Welcome, Guest. Please login or Register for HeroCloud Account.

Author Topic: [Solved] GUIEvents (OnMouseEnter)  (Read 926 times)

PRatliff

  • World Owners
  • ****
  • Posts: 14
    • View Profile
[Solved] GUIEvents (OnMouseEnter)
« on: Jul 03, 12, 12:42:14 PM »

I added the following to the CleanEngine E_AbilityBarClassMethods.

I (perhaps incorrectly) assumed I'd see a message in the Console when my mouse entered the AbilityBar control. I don't see anything.

method onMouseEnter(args references Class GUIMouseEvent)
 println("Mouse entered Control E_AbilityBar");
 
.

Am I missing something? Is this being overridden higher in the chain, somehow? I don't really understand how a GUIControl recieves a GUIEvent, or rather.. who sends the GUIEvent in the first place?

I see a comment in _GUIMethodCallbacksClassMethods near onMouseEnter:


////////////////////////////////////////////////////////////////////
// THE FOLLOWING SECTION IS FOR METHODS WHICH ARE PASSED DOWN TO
// A CONTROL'S ROOT PARENT FOR HANDLING OF EVENTS
// args.source will contain the original control which is passing the event down
////////////////////////////////////////////////////////////////////

Since E_AbilityBar's root parent is E_AbilityBar->GUIPanel->GUIControl->Scripted, I'd expect to see onMouseEnter handled somewhere, but I don't see it.
« Last Edit: Jul 11, 12, 11:33:35 AM by HE-Cooper »
Logged

Arlohian

  • General Accounts
  • *
  • Posts: 43
    • View Profile
Re: GUIEvents (OnMouseEnter)
« Reply #1 on: Jul 06, 12, 11:21:00 AM »

Hi
Yes using this function execute whatever code you put in when a mouse is put over the control.

This works fine for me, i put this bit of code into E_AbilityBarClassMethods. It displays "hello world" in the console, important to remember that there is a console, and a chat in addition to in-game chat window(unless you removed it). 
Code: [Select]
method onMouseEnter(args references Class GUIMouseEvent)
  println("hello world")
.

For mouse-over any specific element simply check for its name(as seen in GUIeditor).
Code: [Select]
method onMouseEnter(args references Class GUIMouseEvent)
  target as NodeRef of Class GUIControl = args.source

  when target.name
  is "test1"
    println("hello world")
  .
.

"Since E_AbilityBar's root parent is E_AbilityBar->GUIPanel->GUIControl->Scripted"
The child class(E_AbilityBar) will overwrite its parents function/method if the function/method has the same name.

Also remember that it might take a few secs to propagate the changes to the server/client after compiling a script.

Another note is the ; at end of your println(), it is not necessary in heroscript, don't think it even throws errors but...

Quite possible you already figured this out by now but still ;) Good luck!
Logged
Fledgling programmer