You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A common issue I have with love GUI libs is no gamepad support. I'm making a game that only uses gamepad/keys, but things like button could work if I could say "this is the current menu selection" or "the user has navigated to this button using the joypad".
I looked at the code and tried to figure it out, from an external-to-imgui perspective. This example is meant to use up/down keys and space to select:
imgui=require'imgui'localuiState=require"imgui.Core.UIState"-- this tracks the current key choicelocalcurrentItem=1-- NOTE: I'm new to imgui so there is probably a better way...functionlove.draw()
uiState.hotItem=currentItemimgui.layout.setFlex(true)
imgui.layout.setColumns(2)
ifimgui.button('A') thenimgui.label('You are clicking on the A button!!')
elseimgui.label('')
endifimgui.button('B') thenimgui.label('You are clicking on the B button!!')
elseimgui.label('')
endifimgui.button('C') thenimgui.label('You are clicking on the C button!!')
elseimgui.label('')
endimgui.draw()
endfunctionlove.keypressed(key)
ifkey=='space' thenuiState.activeItem=currentItemendifkey=='up' thencurrentItem=currentItem-1endifkey=='down' thencurrentItem=currentItem+1endifcurrentItem>imgui['_genID'] thencurrentItem=1endifcurrentItem<1thencurrentItem=imgui['_genID']
endendfunctionlove.keyreleased(key)
ifkey=='space' thenuiState.activeItem=nilendend
It seems to be tracking the current-selection ok, but I can't quite figure out how to say "this was chosen".
Do you have a suggestion of a better way to do it? Is there interest in making this more internal (I am using _genID which seems hacky, but I bet widgets could even track this on their own.)
Here is a ready-made demo, just rename to demo.love: demo.zip
The text was updated successfully, but these errors were encountered:
First, this library looks awesome. Great work!
A common issue I have with love GUI libs is no gamepad support. I'm making a game that only uses gamepad/keys, but things like button could work if I could say "this is the current menu selection" or "the user has navigated to this button using the joypad".
I looked at the code and tried to figure it out, from an external-to-imgui perspective. This example is meant to use up/down keys and space to select:
It seems to be tracking the current-selection ok, but I can't quite figure out how to say "this was chosen".
Do you have a suggestion of a better way to do it? Is there interest in making this more internal (I am using
_genID
which seems hacky, but I bet widgets could even track this on their own.)Here is a ready-made demo, just rename to demo.love:
demo.zip
The text was updated successfully, but these errors were encountered: