+ Reply to Thread
Results 1 to 13 of 13

Thread: Click to target?

  1. #1
    Soulwalker
    Join Date
    Feb 2013
    Posts
    17

    Default Click to target?

    Possible to click a frame and have it target something? Like you click this and it targets, for example yourself. Also I could put this like this, is it possible to have the addon target something?

  2. #2
    Shield of Telara Adelea's Avatar
    Join Date
    Mar 2011
    Posts
    734

    Default

    Yes - you can have a frame target something - how else would unit/raid frames work! You do it by attaching a macro.

    There are a few restrictions though:
    - you cannot change the frames visibility in combat
    - you cannot move the frame in combat
    - you cannot change what the frame targets whilst in combat
    - you cannot activate it without a hardware event - no autotargetting

    Code:
    local ctx = UI.CreateContext("targetter")
    ctx:SetSecureMode("restricted")
    
    local frame = UI.CreateFrame("Frame", "clickframe", ctx)
    frame:SetSecureMode("restricted")
    frame:SetPoint("CENTER", UIParent, "CENTER")
    frame:SetBackgroundColor(0,1,0)
    frame:EventAttach(Event.UI.Input.Mouse.Left.Click, "target @player", "Event.UI.Input.Mouse.Left.Click")
    Last edited by Adelea; 03-28-2013 at 11:48 AM.
    http://forums.riftgame.com/image.php?type=sigpic&userid=125779&dateline=13553  38065

  3. #3
    Soulwalker
    Join Date
    Feb 2013
    Posts
    17

    Default

    Quote Originally Posted by Adelea View Post
    Yes - you can have a frame target something - how else would unit/raid frames work! You do it by attaching a macro.

    There are a few restrictions though:
    - you cannot change the frames visibility in combat
    - you cannot move the frame in combat
    - you cannot change what the frame targets whilst in combat
    - you cannot activate it without a hardware event - no autotargetting

    Code:
    local ctx = UI.CreateContext("targetter")
    ctx:SetSecureMode("restricted")
    
    local frame = UI.CreateFrame("Frame", "clickframe", ctx)
    frame:SetSecureMode("restricted")
    frame:SetPoint("CENTER", UIParent, "CENTER")
    frame:SetBackgroundColor(0,1,0)
    frame:EventAttach(Event.UI.Input.Mouse.Left.Click, "target @player", "Event.UI.Input.Mouse.Left.Click")
    Don't get it.. I'm just getting the incorrect security mode error.. Am I even doing this right?
    function xyz(target, player) -- target == frame
    target:SetSecureMode("restricted")
    target:EventAttach(Event.UI.Input.Mouse.Left.Click , "target "..thoseStupidHealers[player][1], "Target player")

    end
    Also why does my Event.Combat.Heal randomly throw nil value errors? Also why does it output so much of nil values from .heal?
    Last edited by lithi; 03-28-2013 at 01:26 PM.

  4. #4
    Shield of Telara Adelea's Avatar
    Join Date
    Mar 2011
    Posts
    734

    Default

    a) Is the context of the frame also restricted?

    b) Are you trying to change things in combat?
    http://forums.riftgame.com/image.php?type=sigpic&userid=125779&dateline=13553  38065

  5. #5
    Rift Chaser Ferather's Avatar
    Join Date
    Jun 2011
    Posts
    341

    Default

    That's partly true but if you register the events before restrict mode applies you can move or do anything.

    Can you not use mouse over unit? Ill look into making some mock ups.
    Last edited by Ferather; 03-31-2013 at 07:25 AM.

  6. #6
    Shield of Telara Adelea's Avatar
    Join Date
    Mar 2011
    Posts
    734

    Default

    Quote Originally Posted by Ferather View Post
    That's partly true but if you register the events before restrict mode applies you can move or do anything.
    How do you use SuperMeter to target players? Clicking on their names doesnt do it, and a quick perusal of the code doesnt show up anything obvious that would do it - in fact, the term 'restricted' doesnt seem to appear in any of SuperMeters code.

    You can do pretty much anything with non-restricted frames in or out of combat - but this is about restricted frames - since that's the only way to have a frame target something.
    Last edited by Adelea; 03-30-2013 at 11:59 AM.
    http://forums.riftgame.com/image.php?type=sigpic&userid=125779&dateline=13553  38065

  7. #7
    Rift Chaser Ferather's Avatar
    Join Date
    Jun 2011
    Posts
    341

    Default

    You can build a table based on the information provided by the codes I posted, Group number, player ID, name etc can be stored from here.

    Later you can use this information to build text/data for the frames in question, allowing you to change the data in the table the directly effects the frame in or out of combat.

    All you need to do is create a base table results of the information your are given, otherwise you can look for it using inspects and insert that data into your table.

    You can pre create functions and functions that are triggered by events as the addon loads. Then when triggered it can retrieve desired data about a unit, ability or even just looking for player PvP status.



    EG: Setting a frame text from a table:

    Code:
    function MyAddon:SetName(key) ---Key function global: Is a number for my table
    	local text = MyAddonTable.MyFrame[key].Name
    
    	if text then
    		MyFrame[key]:SetText("")
    		MyFrame[key]:SetText(text)
    	end
    end
    
    function MyAddon:SetColour(key) ---Key function global: Is a number for my table
    	local colour = MyAddonTable.MyFrame[key].Calling
    
    	if colour then
    		if calling == "warrior" then
    			MyFrame[key]:SetFontColor(0.0, 0.0, 0.0, 0.0)
    		else calling == "other callings here"
    			MyFrame[key]:SetFontColor(0.0, 0.0, 0.0, 0.0)
    		end
    	end
    end
    
    function MyAddon:SetHealth(key) ---Key function global: Is a number for my table
    	local health = MyAddonTable.MyFrame[key].Health
    
    	if health then
    		MyFrame[key]:SetWidth(---Some Maths here)
    	end
    end
    Last edited by Ferather; 03-31-2013 at 06:15 AM.

  8. #8
    Shield of Telara Adelea's Avatar
    Join Date
    Mar 2011
    Posts
    734

    Default

    Quote Originally Posted by Ferather View Post
    You can build a table based on the information provided by the codes I posted, Group number, player ID, name etc can be stored from here.

    Later you can use this information to build text/data for the frames in question, allowing you to change the data in the table the directly effects the frame in or out of combat. Restricted or not.

    All you need to do is create a base table results of the information your are given, otherwise you can look for it using inspects and insert that data into your table.

    You can pre create functions and functions that are triggered by events as the addon loads. Then when triggered it can retrieve desired data about a unit, ability or even just looking for player PvP status.



    EG: Setting a frame text from a table:

    MyFrame:SetText(MYADDONTABLE[1].MyFrame.Text)

    later I change:

    MYADDONTABLE[1].MyFrame.Text = "Hello"

    to

    MYADDONTABLE[1].MyFrame.Text = "Bye"

    I may need to refresh the frame

    MyFrame:SetText("")
    MyFrame:SetText(MYADDONTABLE.MyFrame.Text)
    Yes - but NONE of this has anything to do with the restrictions on a frame in secure mode - which is what the OP was asking about. He wasnt asking about changing the contents of a frame.

    He asked :

    Possible to click a frame and have it target something? Like you click this and it targets, for example yourself.

    And to do this you need to put a macro on the frame. To do this it needs to be in secure mode. If its in secure mode then you cannot change anything about the frame if you are in combat.
    http://forums.riftgame.com/image.php?type=sigpic&userid=125779&dateline=13553  38065

  9. #9
    Shield of Telara Adelea's Avatar
    Join Date
    Mar 2011
    Posts
    734

    Default

    If you think it can be done, then please post a self-contained code example that will change the players target to themselves, and then does something to the frame you clicked on.

  10. #10
    Rift Chaser Ferather's Avatar
    Join Date
    Jun 2011
    Posts
    341

    Default

    Un restrict the frame, apply the data, re restrict the frame?

    make a boolean for other functions to not give an error when changing the restriction.

    Else im stumped :S
    Last edited by Ferather; 03-30-2013 at 01:45 PM.

  11. #11
    Sword of Telara Semele's Avatar
    Join Date
    Mar 2011
    Posts
    872

    Default

    Quote Originally Posted by Ferather View Post
    Un restrict the frame, apply the data, re restrict the frame?

    make a boolean for other functions to not give an error when changing the restriction.

    Else im stumped :S
    You can't reverse the process for a restricted frame. Once restricted, always restricted.
    Rank 76 Guardian Mage

  12. #12
    Rift Chaser Ferather's Avatar
    Join Date
    Jun 2011
    Posts
    341

    Default

    Can you just use Frame:SetMouseoverUnit(unit)?

    Code:
    RaidFramer = {UI = {}, Event = {}, version = "2.0"}
    Interface = {}
    
    function Interface:new()
    	local o = {state = {}}
    
    	setmetatable(o, self)
    	self.__index = self
    
    	o.context = UI.CreateContext("Context")
    	o.context:SetSecureMode("restricted")
    
    	o.main = UI.CreateFrame("Text", "RaidFramer Main", o.context)
    	o.main:SetPoint("TOPCENTER", UIParent, "TOPCENTER", 0, 0)
    	o.main:SetBackgroundColor(0, 0, 0, 0.2)
    	o.main:SetSecureMode("restricted")
    	o.main:SetFontSize(14)
    	o.main:SetHeight(200)
    	o.main:SetWidth(200)
    
    	function o.main.Event:LeftClick()
    		local unit = Inspect.Unit.Detail("player")
    		
    		if unit and not unit.combat then
    			o.main:SetMouseoverUnit(unit.id)
    			o.main:SetText(unit.name)
    		end
    	end
    
    	function o.main.Event:RightClick()
    		local unit = Inspect.Unit.Detail("player.target")
    		
    		if unit and not unit.combat then
    			o.main:SetMouseoverUnit(unit.id)
    			o.main:SetText(unit.name)
    		end
    	end
    
    	return o
    end
    
    function RaidFramer.Init(addon)
    	if RaidFramer_running then return end
    
    	if addon == "RaidFramer" then
    		RaidFramer.UI.Interface = Interface:new()
    	end
    
    	RaidFramer_running = true
    end
    
    table.insert(Event.Addon.SavedVariables.Load.End, {RaidFramer.Init, "RaidFramer", "Initital Setup"})
    I can set the unit and mouse over prior to combat, and mouse over still works from the set data when in secure mode.

    o.main:EventAttach(Event.UI.Input.Mouse.Left.Click , "target@mouseover", "Target")

    If I could get EventAttach to actually work you could then move on.
    Last edited by Ferather; 03-31-2013 at 09:03 AM.

  13. #13
    Soulwalker
    Join Date
    Mar 2014
    Posts
    1

    Default

    Quote Originally Posted by Ferather View Post
    o.main:EventAttach(Event.UI.Input.Mouse.Left.Click , "target@mouseover", "Target")

    If I could get EventAttach to actually work you could then move on.
    Maybe the API changed, but I found this in a search to create my own unit frames so I thought I'd update it. I had to use frame:EventMacroSet instead of EventAttach:

    Code:
    local ctx = UI.CreateContext("targetter")
    ctx:SetSecureMode("restricted")
    
    local frame = UI.CreateFrame("Frame", "clickframe", ctx)
    frame:SetSecureMode("restricted")
    frame:SetMouseoverUnit("player")
    frame:SetPoint("CENTER", UIParent, "CENTER")
    frame:SetBackgroundColor(0,1,0)
    --frame:EventAttach(Event.UI.Input.Mouse.Left.Click, "target @player", "Event.UI.Input.Mouse.Left.Click")
    frame:EventMacroSet(Event.UI.Input.Mouse.Left.Click, "target @player")

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts