WoW:API SetWhoToUI: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
No edit summary
Line 28: Line 28:


: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.
: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.
:'''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.

Revision as of 23:22, 18 December 2006

WoW API < SetWhoToUI

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

SetWhoToUI(state);

Parameters

Arguments

(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

Nothing.

Notes

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.