Making addons click-through

Making addons click-through

by picartman » Wed Dec 09, 2015 12:09 am

Is there any way that the lua of addons can be modified in a way to make them click-through? For example, ktm threat meter isn't naturally click-through. What I mean by that is if I hold left click on the box, I cannot move my camera around. I don't have much knowledge on addons, but I figured it wouldn't hurt to ask.
picartman
Sergeant
Sergeant
 

Re: Making addons click-through

by Frejl » Wed Dec 09, 2015 6:20 am

Sure, there's a frame method in the API just for this purpose:

FrameName:EnableMouse(false) disables mouse support.
FrameName:EnableMouse(1) enables mouse support.
User avatar
Frejl
Tester
 

Re: Making addons click-through

by LYQ » Wed Dec 09, 2015 11:07 am

well you'll need to get the name of the Frame first, can't check it atm but you can use this macro
/script DEFAULT_CHAT_FRAME:AddMessage( GetMouseFocus():GetName() );
to get the name if your mouse is hovering over the frame, the name will be in your default chatframe. must be something with KTM_ in it^^

let's say the name would be "KTM_Frame" (just for an example)
then you could try it simply with
/run KTM_Frame:EnableMouse(false)

this might be enough, to get it working if that's working you can cut out the /run and copy the code somewhere in a .lua file of the KTM addon
LYQ / Virose
Talentsaver (viewtopic.php?f=63&t=15429) - Totemtimers Enhanced (viewtopic.php?f=63&t=24422)
NostalriusAcceptTrade (viewtopic.php?f=63&t=31729)
User avatar
LYQ
Sergeant Major
Sergeant Major
 

Re: Making addons click-through

by picartman » Wed Dec 09, 2015 6:08 pm

Thank you for the advice, I'll be sure to try that out and keep you informed.
picartman
Sergeant
Sergeant
 

Re: Making addons click-through

by picartman » Thu Dec 10, 2015 5:00 am

I ran your script and found that it's called KLHTM_Frame, and then I ran the /run command and it worked. So what I did was position the frame, typed /ktm autohide so it only shows when I'm in a raid, and therefore I could still move my camera if I accidentally clicked on it during raid.

The issue is that the /run command does not persist through log out. So I used notepad++ to find anything referencing EnableMouse and I found the line of code in KTM_Frame.xml and KTM_OptionsFrame.xml. In the KTM_Frame xml file, I found <Frame name="KLHTM_Frame" parent="UIParent" hidden="true" enableMouse="true" movable="true">

So I changed enableMouse to false, but sadly it didn't work as I logged in and purposely didn't use the /run command. I also tried changing the true to false in the KTM_OptionsFrame file but that also didn't help. Do you have any ideas on what else I can try? I have a macro at the moment to enable click-through, so it's good progress at least:)
picartman
Sergeant
Sergeant
 

Re: Making addons click-through

by LYQ » Thu Dec 10, 2015 8:52 am

hm good progress though, sounded correct. But I guess there must maybe be another spot where it's setting KLHTM_Frame:EnableMouse I would search again if that's the case.

if there is really not another line like that somewhere in the entire code then you could MAYBE try by searching for the last file that's getting loaded from the AddOn, and add the line KLHTM_Frame:EnableMouse(false) to the very end :D I'm not sure if that'd be working and it'd be very sloppy but it might just work out.
You can find out which the last file to load is if you edit the .toc file, the lua file on the very bottom would be the correct one.
If in the toc file the only file to be loaded is the .xml file then you gotta look in that file on the very top which lua files are also getting loaded.

other than that me or another person would need to take a look at the code and try it too, where to correctly change the parameter to disable the mouse. Since your try of changing it sounds like the correcty way to do.
LYQ / Virose
Talentsaver (viewtopic.php?f=63&t=15429) - Totemtimers Enhanced (viewtopic.php?f=63&t=24422)
NostalriusAcceptTrade (viewtopic.php?f=63&t=31729)
User avatar
LYQ
Sergeant Major
Sergeant Major
 

Re: Making addons click-through

by picartman » Thu Dec 10, 2015 6:24 pm

Thanks to your help I got it working :) I checked the .toc, and the last files to load are: Code\GUI\KTM_OptionsGui.lua
Code\GUI\KTM_Frame.xml
Code\GUI\KTM_OptionsFrame.xml

So I changed the enableMouse in the three lines among the two xml files to false, but that didn't help. So I then went into OptionsGui, and at the top it said:
Controls a Gui for viewing and editing settings on the main window. See also
KTM_OptionsFrame.xml, KTM_Gui.lua.

So just in case, I scrolled down in OptionsGui and in the last function-end section, I added the /run command, but that also didn't help. So finally, I went into KTM_Gui.lua, went to the bottom, and added the /run command so it looks like this:
function KLHTM_Frame_OnDragStop()
gui.frame:StopMovingOrSizing();
KLHTM_Frame:EnableMouse(false)
end

Now it works! Thanks for all the help. I used the run command ingame to position the frame where I want, and then now I don't have to worry about it anymore. I'll keep this in mind if I ever need it for other addons :)
picartman
Sergeant
Sergeant
 


Return to Addons & macros