WoW:API SetWhoToUI: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
(→‎Arguments: - Changed string to number. Must have been tired as i wrote it the first time ;))
 
m (Move page script moved page API SetWhoToUI to API SetWhoToUI without leaving a redirect)
 
(5 intermediate revisions by 5 users not shown)
Line 1: Line 1:
<center>'''SetWhoToUI''' - ''Documentation by [[User:Noccy|Noccy]]''</center>
{{wowapi}} __NOTOC__
 
Sets where the result of a [[API SendWho]] request will be handled.


  SetWhoToUI(state);
  SetWhoToUI(state);
:Sets where the result of a [[API SendWho]] request will be handled.


== Parameters ==
== Parameters ==
Line 14: Line 14:


=== Notes ===
=== Notes ===
:During my experiments with this function, the Who dialog still popped up. However, this can be avoided by using FriendsFrame:Hide();
:During [[User:Noccy|my]] experiments with this function, the Who dialog still popped up. However, this can be avoided by using FriendsFrame:Hide(); or a combination of FriendsFrame:UnregisterEvent("WHO_LIST_UPDATE"); and FriendsFrame:RegisterEvent("WHO_LIST_UPDATE");
 
:Another way (perhaps slightly less complex, and easier to get to work with other addons) of avoiding the Who window popping up is to hook the <tt>FriendsFrame_OnEvent</tt> function and not letting the original handle <tt>WHO_LIST_UPDATE</tt> events when your own code is waiting for a reply.  ''Example:''
 
function my_FriendsFrame_OnEvent()
  if not(event == "WHO_LIST_UPDATE" and iAmWaitingForAReply) then
      original_FriendsFrame_OnEvent();
  end
end
original_FriendsFrame_OnEvent = FriendsFrame_OnEvent;
FriendsFrame_OnEvent = my_FriendsFrame_OnEvent;
 
:Of course your code should make sure to reset <tt>iAmWaitinForAReply</tt> periodically (e.g. in case you never get a reply!), and you should probably read [[HOWTO:_Hook_a_Function]] for more info on that subject.


__NOTOC__
:'''Note - Hooking FriendsFrame's OnEvent handler is a really bad idea''', because FriendsFrame contains the raid tab. This would likely cause you a lot of problems with the new secure framework. Using FriendsFrame:Hide() is also probably not a good idea unless you're absolutely sure when your code is going to be run. Otherwise, you may inadvertantly hide the FriendsFrame when the player is using it.
{{Template:WoW API}}

Latest revision as of 04:47, 15 August 2023

WoW API < SetWhoToUI

Sets where the result of a API SendWho request will be handled.

SetWhoToUI(state);

Parameters[edit]

Arguments[edit]

(State)
State
Number - If set to 1, the result of a SendWho will always be returned as a WHO_LIST_UPDATE event. If set to 0 then the result of a SendWho will be returned as a CHAT_MSG_SYSTEM if the list is short, but as a WHO_LIST_UPDATE if the list is long. (from WoW forums)

Returns[edit]

Nothing.

Notes[edit]

During my experiments with this function, the Who dialog still popped up. However, this can be avoided by using FriendsFrame:Hide(); or a combination of FriendsFrame:UnregisterEvent("WHO_LIST_UPDATE"); and FriendsFrame:RegisterEvent("WHO_LIST_UPDATE");
Another way (perhaps slightly less complex, and easier to get to work with other addons) of avoiding the Who window popping up is to hook the FriendsFrame_OnEvent function and not letting the original handle WHO_LIST_UPDATE events when your own code is waiting for a reply. Example:
function my_FriendsFrame_OnEvent()
  if not(event == "WHO_LIST_UPDATE" and iAmWaitingForAReply) then
     original_FriendsFrame_OnEvent();
  end
end

original_FriendsFrame_OnEvent = FriendsFrame_OnEvent;
FriendsFrame_OnEvent = my_FriendsFrame_OnEvent;
Of course your code should make sure to reset iAmWaitinForAReply periodically (e.g. in case you never get a reply!), and you should probably read HOWTO:_Hook_a_Function for more info on that subject.
Note - Hooking FriendsFrame's OnEvent handler is a really bad idea, because FriendsFrame contains the raid tab. This would likely cause you a lot of problems with the new secure framework. Using FriendsFrame:Hide() is also probably not a good idea unless you're absolutely sure when your code is going to be run. Otherwise, you may inadvertantly hide the FriendsFrame when the player is using it.