Open Map From Slash Command
I am trying to open the world map to the zone with the player's current waypoint pinned to it.
If the map is already open, my slash command can set the zone just fine using WorldMapFrame:SetMapID(uiMapID). If the map is closed and I'm out of combat, I can do OpenWorldMap(uiMapID), and it works fine. If I'm in combat, however, OpenWorldMap doesn't work - it's protected. Right now, what I'm doing is waiting for PLAYER_REGEN_ENABLED to open the map, but my understanding is that it should be possible to call protected functions like this so long as the call originates from a hardware event, and entering and sending a slash command seems like a hardware event. So unless I misunderstand, it should be possible to have a slash command open the map window. But I'm really having trouble understanding how precisely these secure handlers/templates work from the documentation I can find. If it is possible, it would be really helpful if someone could give me a simple example of how to make a slash command open the map - that would both solve my problem and help me to understand how to deal with protected functions in general. Or, if I'm misunderstanding and it's not possible, I'm wondering if there's any other way to open the map from a non-secure environment during combat. |
Concerning the very first sentence, what is your end goal? A pin you can immediately shiftclick to share? I have some custom code I can share later when I get the chance that generates a pin at your location that can then share it to a channel or even a whisper directly. This will skip the need for the map entirely.
|
My goal at the moment is literally a command that opens the map to the map with the user's current pin on it.
I already have what you are describing. I'm trying to figure out how to open the map - both to write this particular slash command, and to better understand how protected functions work. |
Slash commands don't allow secure actions, unfortunately. You actually have to click something, such as making a macro and then assigning it to an action button.
|
Quote:
Feels pretty silly that there's no way to open the map frame in combat and no way to make a slash command trigger a secure action when the text is entered and sent via hardware events. |
Quote:
Quote:
Code:
/click MiniMapWorldMapButton Quote:
Apparently, the WorldMapFrame is a protected frame, whether directly or through one of its children. Remember, any frame that has a protected child is also considered a protected frame. |
Quote:
Quote:
Poking around a bit more, it appears that WorldMapFrame isn't actually protected. You can call Show on it during combat, but certain things don't work correctly - like Escape won't clear the frame. The problem is that ShowUIPanel, which is what's normally used to call it, checks CheckProtectedFunctionsAllowed. Quote:
If I'm understanding correctly, it seems like the problem is ultimately just that there's no real way to have a slash command interact with something similar to a SecureHandlerClickTemplate - presumably because there's no option to write a slash command handler that executes in a restricted environment. |
Quote:
Note: /run forces insecure mode and taints execution. Quote:
Quote:
Quote:
Note: No access to ShowUIPanel(). The SecureHandlerTemplates only works off mouse events, OnShow/OnHide, and attribute changes (see SecureStateDriver above). |
with what you said here is a solution to always show the worldmap :
Code:
local handler = CreateFrame("Frame", nil, nil, "SecureHandlerBaseTemplate") you can do a macro if you want If you get : Quote:
|
I believe any usage of the 8.0.1 map data provider API will taint the world map frame.
|
Thank you for the answers.
I can WorldMapFrame:Show() so long as nothing else taints it, but the OnShow doesn't actually handle all the things you would normally get from showing the frame - several of them are handled by ShowUIPanel, which has a check for secure environment. My intent was to alias the call to something else, not to do a native /click [something]. Using the built-in slash command does not work for what I'm trying to do. I assumed that since there were secure handlers that allowed hardware events to change frame attributes in predefined ways within a restricted environment, there might be a secure slash command template of some kind, but it looks like that's not the case. I've just settled for having the addon open the map after combat ends (or set the map correctly if the player opens it manually in the interim). |
don't you know how to read code ?
and if you can do "/click MAP" you can do whatever in secure env SDPhantom pointed you a way to toggle the map here is a solution to always show it i'm sure you can figure out a way to hide it |
Quote:
The answer is that what I'm after is not possible both because there is no secure handler template for custom slash commands (there could be one, but there isn't) and because ShowUIPanel is not accessible from a restricted environment (which it could be, but isn't). |
Quote:
Quote:
|
Quote:
Unless I misunderstand, that does not somehow enable to me to call a protected function during combat using a custom slash command, which is, again, what my question was asking about, and which does not appear to be possible for the reasons others explained and that I mentioned a couple of times - which answers my question. |
a slash command is just multiple buttons pressed
and most of the time, if your function is protected there is a secure trigger, this is the case for WorldMapFrame |
Quote:
|
you create a button that SetBinding all your keyboard to dummy buttons
then your WrapScript your dummy buttons and you interpret the key pressed all that because you don't like /click, which you could customise with buttons, or parameterize |
Quote:
And it isn't "because I don't like /click" - it's because there are a half dozen other functions run from slash commands in this ~2000-line addon and I'd like the keep the interface for it uniform. I am not sure what I did to warrant so much hostility. |
Quote:
Quote:
or thouhand if you have parameters or use the btn option like : /click [btn:1] MAP |
All times are GMT -6. The time now is 05:20 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI