AddOn Studio Wiki
Advertisement

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.
Advertisement