Quantcast
Is is possible to has a OnEnter Script and propagate or unregister mouse clicks? - WoWInterface
 
Thread Tools Display Modes
05-06-21, 12:04 PM   #1
OverCraft
A Defias Bandit
Join Date: May 2021
Posts: 3
Is is possible to has a OnEnter Script and propagate or unregister mouse clicks?

I want to make a frame that has a OnEnter/OnLeave Script with a funciton to make a frame bigger and print more info on it, and at the same time be able to keep moving the character camera op top of the frame with the right mouse click as the frame doesn't exist.

In other words, i need to propagate mouseclicks, or unbind mouse clicks from a frame, but OnEnter Script at the same time binds the mouseclicks too.

Test code:
Code:
    local f = CreateFrame("Frame",nil,UIParent)
    f.tex = f:CreateTexture()
    f.tex:SetAllPoints(f)
    f.tex:SetColorTexture(0.5, 0.2, 1 , 0.5)
    f:SetSize(300,200)
    f:SetPoint("CENTER")
    f:SetScript ("OnEnter", function(self) print ("myfunc")  end)
With
Code:
f:SetPropagateKeyboardInput(true)
    f:EnableMouse(false)
not working and mouse isn't a keyboard . EnableMouse(false) removes OnEnter Script.

Making the frame a button and
Code:
f:RegisterForClicks()
void RegisterForClicks not working

I tried to manually move the camera with
Code:
f:SetScript("OnMouseDown",function (self,button) if button=="RightButton" then CameraOrSelectOrMoveStart()  end end)
f:SetScript("OnMouseUp",function (self,button) if button=="RightButton" then  CameraOrSelectOrMoveStop()  end end)
They are protected and I cannot use them

and same thing with
Code:
MouselookStart()
MouselookStop()
And I think they are not even related with the camera movement.

I got no more ideas, need some help of you. Thanks!
  Reply With Quote
05-06-21, 12:35 PM   #2
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,638
Unfortunately OnEnter and OnLeave doesn't involve a mouse button being clicked. The frame is interactive.

However, you can register for OnMouseDown or OnMouseUp and check for a specific button being clicked to interact with the frame only on left click. However, whether that allows you to click behind it with the right mouse button is another thing. As you have been doing, all you can do is try things out. Which by the looks of your post you have tried to do.

Hopefully if someone has done what you want they can either point you to an addon that has it working for you to look at or can talk through how they did it.

As far as I am aware a frame is either interactive or non-interactive based on whether you have chosen to use the mouse with it or just using it as an overlay display like a hud.
__________________

Last edited by Xrystal : 05-06-21 at 12:37 PM.
  Reply With Quote
05-06-21, 01:14 PM   #3
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,417
You said moving the camera so this might give you something to start/work with (as currently coded, requires mouseleft to be held down to move the camera but it's up to you):
Lua Code:
  1. local f = CreateFrame("Button", "SomeOnEnterFrame", WorldFrame)
  2. f:SetSize(200, 200)
  3. f:SetPoint("TOPLEFT")
  4. f.t = f:CreateTexture()
  5. f.t:SetAllPoints()
  6. f.t:SetTexture("abc")
  7. f:RegisterForClicks("LeftButtonDown", "LeftButtonUp")
  8. f:SetScript("OnEnter", function(self)
  9.     print("Entered")
  10.     self:SetSize(400, 400)
  11. end)
  12. f:SetScript("OnLeave", function(self)
  13.     print("Left")
  14.     if self.MouseLooking or MouseIsOver(self) then
  15.         return
  16.     end
  17.     self:SetSize(200, 200)
  18. end)
  19. f:SetScript("OnClick", function(self, button, down)
  20.     if down then
  21.         if not self.MouseLooking then
  22.             self.MouseLooking = true
  23.             MouselookStart()
  24.         else
  25.             self.MouseLooking = nil
  26.             MouselookStop()
  27.         end
  28.     end
  29. end)
  30. WorldFrame:HookScript("OnMouseUp", function(self, button)
  31.     if SomeOnEnterFrame.MouseLooking then
  32.         SomeOnEnterFrame:Click(button, true)
  33.     end
  34. end)
... or not.

You can't have MouseLook "running" and interact with UI elements at the same time using the mouse.

If MouseLook gets "stuck on" while figuring out all the ins and outs you might need to address, clicking both buttons should unlock it.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 05-06-21 at 02:29 PM.
  Reply With Quote
05-06-21, 02:42 PM   #4
OverCraft
A Defias Bandit
Join Date: May 2021
Posts: 3
Originally Posted by Fizzlemizz View Post
You said moving the camera so this might give you something to start/work with (requires mouseleft to be held down to move the camera):
Lua Code:
  1. local f = CreateFrame("Button", "SomeOnEnterFrame", WorldFrame)
  2. f:SetSize(200, 200)
  3. f:SetPoint("TOPLEFT")
  4. f.t = f:CreateTexture()
  5. f.t:SetAllPoints()
  6. f.t:SetTexture("abc")
  7. f:RegisterForClicks("LeftButtonDown", "LeftButtonUp")
  8. f:SetScript("OnEnter", function(self)
  9.     print("Entered")
  10.     self:SetSize(400, 400)
  11. end)
  12. f:SetScript("OnLeave", function(self)
  13.     print("Left")
  14.     if self.MouseLooking or MouseIsOver(self) then
  15.         return
  16.     end
  17.     self:SetSize(200, 200)
  18. end)
  19. f:SetScript("OnClick", function(self, button, down)
  20.     if down then
  21.         if not self.MouseLooking then
  22.             self.MouseLooking = true
  23.             MouselookStart()
  24.         else
  25.             self.MouseLooking = nil
  26.             MouselookStop()
  27.         end
  28.     end
  29. end)
  30. WorldFrame:HookScript("OnMouseUp", function(self, button)
  31.     if SomeOnEnterFrame.MouseLooking then
  32.         SomeOnEnterFrame:Click(button, true)
  33.     end
  34. end)
... or not.

If MouseLook gets "stuck on" while figuring out all the ins and outs you might need to address, clicking both buttons should unlock it.
Thanks a lot, i was very close to it but never heared about WorldFrame. Do you think it is possible to use rightclick to do that and leftclick with the same behaviour as WorldFrame does? clicking object, targeting units etc.. ? To be a complete transparent frame.
  Reply With Quote
05-06-21, 02:45 PM   #5
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,417
WorldFrame is where the focus goes when entering MouseLook.

Once you enter MouseLook you lose the cursor just like running using both buttons down (which is essentially a protected StartMoving + MouseLookStart).

Edit: I might have over (or under) interpreted the last question.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 05-06-21 at 04:11 PM.
  Reply With Quote
05-06-21, 04:29 PM   #6
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,417
Maybe your looking for something more like:

Lua Code:
  1. local f = CreateFrame("Frame", "SomeOnEnterFrame")
  2. f:SetSize(200, 200)
  3. f:SetPoint("TOPLEFT")
  4. f.t = f:CreateTexture()
  5. f.t:SetAllPoints()
  6. f.t:SetTexture("abc")
  7. f.t:SetAlpha(0.4)
  8. f:SetScript("OnUpdate", function(self)
  9.     if MouseIsOver(self) then
  10.         if not self.BigSize then
  11.             self.BigSize = true
  12.             self:SetSize(400, 400)
  13.         end
  14.     else
  15.         if self.BigSize then
  16.             self.BigSize = nil
  17.             self:SetSize(200, 200)
  18.         end
  19.     end
  20. end)
Depending on what else you want to do with the frame.

The setting of BigSize could also include whatever you wanted to do OnEnter/OnLeave.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
05-07-21, 07:14 AM   #7
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
Originally Posted by OverCraft View Post
I want to make a frame that has a OnEnter/OnLeave Script with a funciton to make a frame bigger and print more info on it, and at the same time be able to keep moving the character camera op top of the frame with the right mouse click as the frame doesn't exist.
Blizzard added that functionality awhile ago:
Lua Code:
  1. local f = CreateFrame("Frame",nil,UIParent)
  2. f.tex = f:CreateTexture()
  3. f.tex:SetAllPoints(f)
  4. f.tex:SetColorTexture(0.5, 0.2, 1 , 0.5)
  5. f:SetSize(300,200)
  6. f:SetPoint("CENTER")
  7. f:SetScript ("OnEnter", function(self) print("OnEnter")  end)
  8. f:SetScript ("OnLeave", function(self) print("OnLeave")  end)
  9. f:EnableMouse(false)
  10. f:SetMouseMotionEnabled(true)
The order of the last four lines is important. Setting a script dealing with the mouse automatically enables the mouse. So set your OnEnter/OnLeave scripts, then disable the mouse, and finally enable motion scripts only.
  Reply With Quote
05-07-21, 07:49 AM   #8
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,638
So, even though you later disable the mouse, because you have set up the scripts it will work for those actions ? And, nice find with the SetMouseMotionEnabled function. Not seen that one yet myself.

Originally Posted by Vrul View Post
Blizzard added that functionality awhile ago:
Lua Code:
  1. local f = CreateFrame("Frame",nil,UIParent)
  2. f.tex = f:CreateTexture()
  3. f.tex:SetAllPoints(f)
  4. f.tex:SetColorTexture(0.5, 0.2, 1 , 0.5)
  5. f:SetSize(300,200)
  6. f:SetPoint("CENTER")
  7. f:SetScript ("OnEnter", function(self) print("OnEnter")  end)
  8. f:SetScript ("OnLeave", function(self) print("OnLeave")  end)
  9. f:EnableMouse(false)
  10. f:SetMouseMotionEnabled(true)
The order of the last four lines is important. Setting a script dealing with the mouse automatically enables the mouse. So set your OnEnter/OnLeave scripts, then disable the mouse, and finally enable motion scripts only.
__________________
  Reply With Quote
05-07-21, 09:39 PM   #9
OverCraft
A Defias Bandit
Join Date: May 2021
Posts: 3
Originally Posted by Vrul View Post
Blizzard added that functionality awhile ago:
Lua Code:
  1. local f = CreateFrame("Frame",nil,UIParent)
  2. f.tex = f:CreateTexture()
  3. f.tex:SetAllPoints(f)
  4. f.tex:SetColorTexture(0.5, 0.2, 1 , 0.5)
  5. f:SetSize(300,200)
  6. f:SetPoint("CENTER")
  7. f:SetScript ("OnEnter", function(self) print("OnEnter")  end)
  8. f:SetScript ("OnLeave", function(self) print("OnLeave")  end)
  9. f:EnableMouse(false)
  10. f:SetMouseMotionEnabled(true)
The order of the last four lines is important. Setting a script dealing with the mouse automatically enables the mouse. So set your OnEnter/OnLeave scripts, then disable the mouse, and finally enable motion scripts only.
The @Fizzlemizz OnUpdate idea was good, but a little too agressive. This is actually the cleanest version, very nice trick Thanks everybody for the help!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Is is possible to has a OnEnter Script and propagate or unregister mouse clicks?

Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off