Thread Tools Display Modes
08/14/14, 12:41 PM   #1
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,989
Disable key from standard ESO keystrip?

Is it possible to disable a key from the standard ESO gui's keystrip, so nothing happens if a user presses the key?

I'd like to react on something and after this disable the following keybindings:
UI_SHORTCUT_PRIMARY -- Primary action/Accept
UI_SHORTCUT_SECONDARY -- Secondary Action
UI_SHORTCUT_TERTIARY -- Tertiary Action

I've searched a while now and all I found is how you are able to change the texture, make them invisible, not mouse clickable (but they still work then, if someone presses the shortcut on his keybord/controller).

With zgoo I found methods like SetKeybind() and SetKeybindEnabled() for controls. But they only seem to set the keybind to the control. I wasn't able to disable them with it.

I also found a function you could use, if you stay out of combat:
UnbindKeyFromAction protected (luaindex layerIndex, luaindex categoryIndex, luaindex actionIndex, luaindex bindingIndex)
But I did not manage to get all needed parameters to unbind something. Maybe it's the wrong function too.
And I would have to rebind the unbound keys afterwards again.

Thanks for any help.

Last edited by Baertram : 08/14/14 at 01:02 PM.
  Reply With Quote
08/14/14, 03:40 PM   #2
Fyrakin
 
Fyrakin's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 129
Did you try making a toplevel control and enable keyboard on it?
  Reply With Quote
08/14/14, 04:05 PM   #3
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 648
I have not had any luck with this.
  Reply With Quote
08/14/14, 04:48 PM   #4
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,578
Haven't tested this myself, but you could try something like this:

init:
Code:
local keybindButtonDescriptor = KEYBIND_STRIP.keybinds["UI_SHORTCUT_PRIMARY"]
local oldEnabled = keybindButtonDescriptor.enabled
disable:
Code:
keybindButtonDescriptor.enabled = false -- can also be a function that returns a boolean
KEYBIND_STRIP:UpdateKeybindButton(keybindButtonDescriptor)
enable:
Code:
keybindButtonDescriptor.enabled = oldEnabled
KEYBIND_STRIP:UpdateKeybindButton(keybindButtonDescriptor)
if this does not work, you could also replace keybindButtonDescriptor.callback with an empty function

Last edited by sirinsidiator : 08/14/14 at 04:51 PM.
  Reply With Quote
08/15/14, 08:15 AM   #5
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,989
Originally Posted by sirinsidiator View Post
Haven't tested this myself, but you could try something like this:

init:
Code:
local keybindButtonDescriptor = KEYBIND_STRIP.keybinds["UI_SHORTCUT_PRIMARY"]
local oldEnabled = keybindButtonDescriptor.enabled
disable:
Code:
keybindButtonDescriptor.enabled = false -- can also be a function that returns a boolean
KEYBIND_STRIP:UpdateKeybindButton(keybindButtonDescriptor)
enable:
Code:
keybindButtonDescriptor.enabled = oldEnabled
KEYBIND_STRIP:UpdateKeybindButton(keybindButtonDescriptor)
if this does not work, you could also replace keybindButtonDescriptor.callback with an empty function
I've tested it but it will only remove the text next to the keybind button and deactivate the onclick method (which leads to an error if you press the button).
So you'll see the buttons on the keybind strip at the bottom, for example [E] and [R]. But No text next to it anymore.
If you click them or press the key on your keayboard a lua error occurs:

Code:
EsoUI/Libraries/ZO_KeybindStrip/ZO_KeybindStrip.lua:20: attempt to index a boolean value
stack traceback:
	EsoUI/Libraries/ZO_KeybindStrip/ZO_KeybindStrip.lua:20: in function 'OnButtonClicked'
	EsoUI/Libraries/ZO_KeybindStrip/ZO_KeybindStrip.lua:234: in function 'ZO_KeybindStrip:TryHandlingKeybindDown'
	(tail call): ?
	(tail call): ?
But it's a good attempt. Maybe one can remove the controls from the keybind strip bar at the bottom (or make them invisible) and overwrite the onclick handler somehowe to let it do nothing.

I'll try to play around with
ZO_KeybindStrip_HandleKeybindDown
ZO_KeybindStrip_HandleKeybindUp

Last edited by Baertram : 08/15/14 at 08:35 AM.
  Reply With Quote
08/15/14, 11:57 AM   #6
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,578
After some experimenting I got a working example:
Code:
	local button = nil
	TRADING_HOUSE_SCENE:RegisterCallback("StateChange", function()
		d("state change")
		zo_callLater(function()
			if(button) then return end
			button = KEYBIND_STRIP.keybinds["UI_SHORTCUT_TERTIARY"]
			local keybindButtonDescriptor = button.keybindButtonDescriptor
			local oldEnabled = keybindButtonDescriptor.enabled
			local oldCallback = keybindButtonDescriptor.callback

			d("disable")
			keybindButtonDescriptor.enabled = false
			keybindButtonDescriptor.callback = function() end
			KEYBIND_STRIP:UpdateKeybindButton(keybindButtonDescriptor)

			zo_callLater(function()
				d("enable")
				keybindButtonDescriptor.enabled = oldEnabled
				keybindButtonDescriptor.callback = oldCallback
				KEYBIND_STRIP:UpdateKeybindButton(keybindButtonDescriptor)
			end, 5000)
		end, 200)
	end)
It disables the guild switch keybind strip in the guild store for 5 seconds and then enables it again.
  Reply With Quote
08/15/14, 12:02 PM   #7
Fyrakin
 
Fyrakin's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 129
I'm not sure if that would help you but I would do the following
Code:
ZO_PreHook(KEYBIND_STRIP, "TryHandlingKeybindDown", function(keybind) 
-- code which decides where you need to do something about keybind and return truwe which tells that you handled it and original function doesn't have to be called or return false or nil so it acts as normal
 end)
  Reply With Quote
04/18/22, 02:25 AM   #8
remosito
AddOn Author - Click to view addons
Join Date: Dec 2019
Posts: 30
for what it's worth....

more necro bounties :-)

might be useful to somebody else:

I wanted to get rid of the "Sell all Junk" button in the store window...

surprisingly just changing visibility was enough. Hitting the associated keybind "x" does nothing anymore....

Code:
	local storekeybindstrip = STORE_WINDOW.keybindStripDescriptor
	for k,v in pairs(storekeybindstrip) do
		if type(v) == "table" and v["keybind"] == "UI_SHORTCUT_NEGATIVE" then 
			STORE_WINDOW.keybindStripDescriptor[k]["visible"] = function() return false end
		end
	end
thanks circonian for pointing me the way of the STORE_WINDOW.keybindStripDescriptor!

Now to hunt down the inventory window keybindstrip to get rid of the "Destroy all junk" keybind

if that one behaves differently I'll come back to update my post..
  Reply With Quote
05/01/22, 09:11 AM   #9
remosito
AddOn Author - Click to view addons
Join Date: Dec 2019
Posts: 30
Originally Posted by remosito View Post

Now to hunt down the inventory window keybindstrip to get rid of the "Destroy all junk" keybind

if that one behaves differently I'll come back to update my post..
That was fruitless... :-/

When following down data structures always ended up at some strange UserData values...

google made me think this is where it all goes over into C coded functionality...


But found a workaround, ESO calls a predefined Dialog upon pressing that button from ingame/globals/ingamedialogs.lua

So I just overwrote that one in my code:

Code:
	ESO_Dialogs["DESTROY_ALL_JUNK"] = {
		title =	{ text = SI_PROMPT_TITLE_DESTROY_ITEMS, },
		mainText = { text = "Functionality disabled by Addon",},
		buttons = {	[1] = {	text =       SI_DIALOG_DECLINE,	},},
	}
Not as nice, but works....
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » Disable key from standard ESO keystrip?


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off