Go to Page... |
Thread Tools | Display Modes |
03/30/15, 04:50 PM | #1 |
PreHooking Dialog's OnKeyUp -> Primary + Abort keybinding do not work anymore
Hey there,
I just tested somethign with a dialog and if I PreHook the OnKeyUp handler for the dialog + set dialog:SetKeyboardEnabled(true) (which is needed so the OnkeyUp method will be recognized at all) the standard keybindings of this dialog won#t work anymore :-( Any idea to achieve both: 1. Get listener on handler OnKeyUp and execute my own function 2. Get standrd keybindings to work for the accept and abort buttons of this dialog My idea was: -Get the keycodes for the primary and abort dialog keys (any function to read this from the settings to get the keycodes in the desired keycode style, e.g. KEY_E for the "e" button?) -Implement the OnKeyUp function to react on these two keycodes (accept and abort) as well Only problem is: If I tried to just execute the "callback" function of the accpet button by my source code I'll get an error because of another addon (Stacked). This is because Stacked already copied the original handler of this dialog's accept button and has implemented an own one. I can't see why the error is thrown but it does Here is my source code so far: Lua Code:
Last edited by Baertram : 04/02/15 at 11:41 AM. |
|
03/30/15, 09:12 PM | #2 |
|
Can you register the callback elsewhere or can only one control capture keybinds?
If they all register, use the OnKeyUp event for a different control (either one in scene or add your own to the scene). |
03/30/15, 10:36 PM | #3 |
|
There may be a way to avoid the problem entirely, but this would be a simple fix.
Just handle those keys that aren't working yourself: Lua Code:
Last edited by circonian : 03/30/15 at 10:39 PM. |
03/31/15, 01:47 AM | #4 |
@Circonian Thx. I tried this already (as I've written above) but not everyone is using KEY_E and KEY_ALT as the keybindings for accept or cancel.
Am I able to get the assigned keybindings somehow to react ont eh correct keys? Maybe someone changed it to KEY_G and KEY_CTRL. And as I said too the addon "stacked" raises an error if I try to call the callback function of the accept button. I'm not sure WHY it does this. It seems to copy the original callback to a backup function, exchange the callback function then with an own one, call the original function and then it's code to refresh some keybindings (so it's a Post-hook). Maybe I can pre-Hook the callback function of the accept button to avoid the error. @Sasky Good idea, I'll see if I can register the keybindings to the scene and then check if the dialog is shown. But I hope it won't disable keybinds of the keybind strip for all teh scene elements this way ^^ |
|
03/31/15, 07:24 AM | #5 | |
|
However, I think it'd be better if you got it to work without replacing existing bindings. |
|
03/31/15, 08:31 AM | #6 |
Thx merlight.
I'd love to get this to work but I don't know how? Everytime I enable the SetKeyboardEnabled(true) function the keybindings seem to get disabled :-( And without this keyboard enabled function I'm not able to react on the keys :-( Maybe I can get it to work by using the scene somehow. |
|
03/31/15, 04:11 PM | #7 |
|
Oh yeah, my bad. I guess by the time I got done looking at it I forgot you said all of that.
EDIT: Oh yeah, and the reason the buttons stop working when you turn on SetKeyboardEnabled(true) is because if, for example, the chat edit box (to enter chat) had focus & its keyboardEnabled...if it did not block keybind buttons you would start walking & opening all kinds of windows as you typed and those dialog buttons are not keyboardEnabled controls they are called/fired from keybinds. Here you go: Lua Code:
One thing you may (or may not) have thought of (I didn't look at any of the other code) (although unlikely) do you have to worry about if they have changed those primary/negative keybinds to a keypress you are using to switch guilds (KEY_1, KEY_NUMPAD1, exc..)? PS: I like the easy way of switching guild banks...How about adding scrollWheel support to just scroll the mouse wheel to switch guilds. Last edited by circonian : 03/31/15 at 04:23 PM. |
03/31/15, 04:37 PM | #8 |
Thanks again. Your method is exactly how I managed to solve it some hours ago ;-)
Oh and I don't think anyone uses the keys 1 to 5 for the keybinds of accept&decline as they are pre-designed to be used for the character's skills. if anyone is using them he/she should report it and I'll start to think about at this time hehe I was thinking about the scroll wheel too but did not find out how to hook the scroll wheel on that dialog until now. Did not put much effort in it yet, maybe I'll add it in the future. |
|
03/31/15, 04:46 PM | #9 |
|
EDIT: bah, I deleted it. Lets try that again:
You could move the primary/negative key checks to the top, then that way they will get tested first. That way if someone has KEY_NUMPAD1 bound as their primary it would still work and they could still use KEY_1 to change guilds. Lua Code:
Last edited by circonian : 03/31/15 at 05:40 PM. |
04/01/15, 09:24 AM | #10 |
Good idea, I'll change this in the next version.
I'm currntly investigating the mouse scrolling but I'm not sure until now how to hook it at the dialog. Maybe I need to start to listen to all mouse scroll events when then guild select dialog appears (prehook OnShow and set variable to "dialog is active") and then unhook / change variable again if the dialog gets closed. Ok I got it to work and implemented + released it. You can select your guild by help of the mouse wheel too. Last edited by Baertram : 04/01/15 at 10:59 AM. |
|
04/02/15, 11:38 AM | #11 |
I got a new problem now. The addon is working so far. Mouse wheel and keyboard keys 1 to 5 will switch the combobox at the guild bank selection popup to the according guild.
The mousewheel is working directly after the 1st time you open the guild bank selector popup. But the keyboard keys 1 to 5 won#t work at this time? You'll have to close the dialog and reopen it again. After this the keys are working too. Currently I hooked the OnShow method of the dialog, prehooked the OnKeyUp function of the dialog and enabled the keyboard then. But it seems that the dialog won't register the OnKeyUp handler's PreHook until you "reload" the dialog (by closing and opening it again)? Any ideas how to fix this? Here is the current source code: Lua Code:
Last edited by Baertram : 04/02/15 at 11:41 AM. |
|
04/02/15, 04:27 PM | #12 |
|
I glanced at the code, don't have much time have to leave for work soon...but will look at it later when I get home.
I only glanced at it and didn't have time to look for the thing you actually asked about....but I can say a couple of things I noticed so far: I did not test any of this and didn't have much time to look at the code, so I might have overlooked something or made a type-o. Lua Code:
Couldn't this replace that entire function? Lua Code:
This might also make your life easier. I see a lot of manipulation with the combo box & other things to mess with getting/setting the selected guild. You don't need to do any of that, I believe this will allow you to eliminate a LOT of code...you can use: Lua Code:
Again I only glanced at it, but I think those few things could take place of several functions it looks like. Here are a coupld of examples: Lua Code:
I see a lot of code dealing with the last index of the combo box. I'm guessing that allows the user to scroll from the last guild in the list to the first. You could probably get rid of that function entirely...and replace it with something like this: Lua Code:
Last edited by circonian : 04/02/15 at 04:31 PM. |
04/02/15, 05:04 PM | #13 |
Thx for the info about GetNumGuilds() and the other functions.
One question: SelectGuildBank(guild id) Will this change the guild bank directly or do I have to accept the selected guild before it changes it? |
|
04/02/15, 09:04 PM | #14 | |
|
Also I don't think you need these. They return nil, so I don't think they have those handlers by default, so I don't think theres anything to restore later. Lua Code:
Last edited by circonian : 04/02/15 at 09:54 PM. |
|
04/02/15, 11:02 PM | #15 | |
|
Lua Code:
|
|
04/04/15, 04:44 PM | #16 | |
I've just added them so they will be compatible in the future with other addons playing around with these functions. But as I replace them with mine they shouldn't be necessary I guess, you are right
|
||
ESOUI » Developer Discussions » Lua/XML Help » PreHooking Dialog's OnKeyUp -> Primary + Abort keybinding do not work anymore |
«
Previous Thread
|
Next Thread
»
|
Thread Tools | |
Display Modes | |
|
|