- Joined
- Aug 22, 2020
- Messages
- 2
Hey gang, I'm wondering if it's possible to simulate clicks on inventory items. This could, for example, be a nice way to give items non-numberpad hotkeys. Disclaimer: sure, there are lots of other ways to fake hotkeys for items, but they all have drawbacks. I'm not looking for hacky alternatives, just want to know whether or not this approach is possible.
So, inventory button frames are defined as SIMPLEBUTTONs in war3.w3mod:ui\framedef\ui\reforged\inventorybar.fdf:
And SIMPLEBUTTON frames can have CONTROL_CLICK events (according to [JASS/AI] - UI: FrameEvents and FrameTypes) which, from my brief testing, can be triggered by
but nothing happens (though triggers with a FRAMEEVENT_CONTROL_CLICK event for InventoryButton_0 will run, but that doesn't help much).
Maybe I'm using the wrong frame? I found that "InventoryButton_0" has one child, an
ORIGIN_FRAME_ITEM_BUTTON, that at map init does not have any children. After having a unit pick up an item, the ORIGIN_FRAME_ITEM_BUTTON gets one child frame, but I'm not sure what it is. I've tried calling clicks to those two frames like so:
but still nothing. Any ideas?
So, inventory button frames are defined as SIMPLEBUTTONs in war3.w3mod:ui\framedef\ui\reforged\inventorybar.fdf:
Code:
Frame "SIMPLEBUTTON" "InventoryButton_0" INHERITS "InventoryButtonTemplate" {
SetPoint TOPLEFT, "SimpleInventoryBar", TOPRIGHT, 0.115, -0.0509,
}
And SIMPLEBUTTON frames can have CONTROL_CLICK events (according to [JASS/AI] - UI: FrameEvents and FrameTypes) which, from my brief testing, can be triggered by
BlzFrameClick()
. I would hope that, if a selected unit has a usable item in its top-left inventory slot, then I could simulate a user clicking that item like so:
vJASS:
local framehandle f = BlzGetFrameByName("InventoryButton_0", 0)
call BlzFrameClick(f)
but nothing happens (though triggers with a FRAMEEVENT_CONTROL_CLICK event for InventoryButton_0 will run, but that doesn't help much).
Maybe I'm using the wrong frame? I found that "InventoryButton_0" has one child, an
ORIGIN_FRAME_ITEM_BUTTON, that at map init does not have any children. After having a unit pick up an item, the ORIGIN_FRAME_ITEM_BUTTON gets one child frame, but I'm not sure what it is. I've tried calling clicks to those two frames like so:
vJASS:
// Using ORIGIN_FRAME_ITEM_BUTTON
local framehandle f = BlzGetOriginFrame(ORIGIN_FRAME_ITEM_BUTTON, 0)
call BlzFrameClick(f)
// Now using the mysterious child
set f = BlzFrameGetChild(f, 0)
call BlzFrameClick(f)