Poster: Itchyban at 5/17/2005 5:32:17 PM PDT Subject: object = CursorIsOver() ?? |
| |
Any easy way to determine the object that the cursor is presently over?
(Yeah, yeah, it's always over UIParent. You know what I'm asking!)[ post edited by Itchyban ]
Yes, one and the same from Veeshan.
|
| | http://forums.worldofwarcraft.com/thread.aspx?fn=wow-interface-customization&t=138577&p=#post138577 |
| |
Poster: slouken at 5/19/2005 2:57:04 PM PDT Subject: Re: object = CursorIsOver() ?? |
| |
The next test server update will have the function GetMouseFocus(), which will return the frame which has the current mouse focus (not the name, the actual frame).
If you're just changing state based on whether the mouse is over your frame, make sure you have mouse events enabled for the frame, and then set up OnEnter and OnLeave handlers for the frame.
|
| | http://forums.worldofwarcraft.com/thread.aspx?fn=wow-interface-customization&t=138577&p=#post139748 |
Poster: slouken at 5/26/2005 8:35:58 PM PDT Subject: Re: object = CursorIsOver() ?? |
| |
By the way, would it be more useful to return the name of the frame? This is the first function that actually returns an object, and I'm hesitant to start mixing metaphors.
|
| | http://forums.worldofwarcraft.com/thread.aspx?fn=wow-interface-customization&t=138577&p=#post144780 |
Poster: slouken at 5/26/2005 9:33:36 PM PDT Subject: Re: object = CursorIsOver() ?? |
| |
Actually, the way the system is set up, I can only return named frames. Anonymous frames are not available to the scripting system at all.
|
| | http://forums.worldofwarcraft.com/thread.aspx?fn=wow-interface-customization&t=138577&p=#post144806 |
Poster: slouken at 5/26/2005 10:34:44 PM PDT Subject: Re: object = CursorIsOver() ?? |
| |
Well, if I return the name, if you actually need the frame itself, it's simply:
frame = getglobal(GetMouseFocus());
As for returning anonymous frames, I think you need to name your frame in order to have mouse events delivered to it, so you'll never actually find the mouse focused on an unnamed frame.
|
| | http://forums.worldofwarcraft.com/thread.aspx?fn=wow-interface-customization&t=138577&p=#post144823 |
Poster: slouken at 5/26/2005 11:06:44 PM PDT Subject: Re: object = CursorIsOver() ?? |
| |
Well, an understanding of how the UI is rendered would help:
There are several strata that a frame goes into, e.g. background, normal, dialog, tooltip. A strata simply means that all frames in one strata will be rendered above frames in a lower strata, and below frames in a higher strata.
Within a strata, each frame has a frame level, which determines the order in which it is rendered. The optimal layout is to have all frames in the same strata at the same frame level, since they can be batched and rendered at the same time. When a "toplevel" frame is clicked on, it is raised above other frames in the strata.
Within a frame, there are several draw layers, e.g. background, artwork, overlay, which can contain textures and fontstrings. Within a single draw layer, textures are rendered first, and then fontstrings are rendered afterwards, so text always shows above textures within a single draw layer. Other than that, there is no defined render order, so if you have two overlapping textures in the same draw layer, you never know which will overlap the other.
Only frames can get mouse events, and then only if they have mouse event handlers or are frame types which are clickable (buttons). The mouse focus goes to the frame which is registered for mouse events with the highest strata and the highest frame level under the cursor.
I hope that helps!
|
| | http://forums.worldofwarcraft.com/thread.aspx?fn=wow-interface-customization&t=138577&p=#post144837 |
Poster: slouken at 5/27/2005 11:11:15 AM PDT Subject: Re: object = CursorIsOver() ?? |
| |
Okay, it will return the object, not the name. (I see GetParent() does too, which was what I was worried about)
Thanks for the feedback!
|
| | http://forums.worldofwarcraft.com/thread.aspx?fn=wow-interface-customization&t=138577&p=#post145053 |
Poster: slouken at 5/27/2005 12:27:33 PM PDT Subject: Re: object = CursorIsOver() ?? |
| |
Yes, they exist, and they get events, but only the first frame actually is added to the global environment by name.
Only named frames/textures/fontstrings are added to the scripting system to save memory, since each object requires a table allocation.
|
| | http://forums.worldofwarcraft.com/thread.aspx?fn=wow-interface-customization&t=138577&p=#post145092 |
Poster: slouken at 5/27/2005 4:40:30 PM PDT Subject: Re: object = CursorIsOver() ?? |
| |
Q u o t e: I'm curious now :) If you have a named frame A with an unnamed child B which has a named child C, and you call C:GetParent(), what do you get back? Does it return A? That seems weird since it's not the actual parent...
You get nil.
|
| | http://forums.worldofwarcraft.com/thread.aspx?fn=wow-interface-customization&t=138577&p=#post145311 |
Poster: slouken at 5/27/2005 4:41:41 PM PDT Subject: Re: object = CursorIsOver() ?? |
| |
I'm tempted to add all frames (not textures or fontstrings) to the scripting system, since most of them have a name already, and returning nil for C:GetParent() in the example above is obviously not very helpful. :)
|
| | http://forums.worldofwarcraft.com/thread.aspx?fn=wow-interface-customization&t=138577&p=#post145312 |
Poster: slouken at 5/31/2005 10:53:51 AM PDT Subject: Re: object = CursorIsOver() ?? |
| |
Q u o t e: I'm tempted to add all frames (not textures or fontstrings) to the scripting system, since most of them have a name already, and returning nil for C:GetParent() in the example above is obviously not very helpful. :)
Okay, this will be in the 1.6 content patch. It shouldn't affect anyone much, but it does mean that you don't need to name your frame to get events, and you can call frame:GetParent():GetParent(); and have it work with an anonymous parent.
|
| | http://forums.worldofwarcraft.com/thread.aspx?fn=wow-interface-customization&t=138577&p=#post147557 |
Poster: slouken at 6/1/2005 9:58:00 AM PDT Subject: Re: object = CursorIsOver() ?? |
| |
You got it. :) (1.6)
|
| | http://forums.worldofwarcraft.com/thread.aspx?fn=wow-interface-customization&t=138577&p=#post148239 |
Poster: slouken at 6/1/2005 11:01:37 AM PDT Subject: Re: object = CursorIsOver() ?? |
| |
You're welcome. :)
|
| | http://forums.worldofwarcraft.com/thread.aspx?fn=wow-interface-customization&t=138577&p=#post148289 |