treeform / fidget

Figma based UI library for nim, with HTML and OpenGL backends.
MIT License
763 stars 32 forks source link

Tab in Text Not Usable #166

Closed MorganPeterson closed 2 years ago

MorganPeterson commented 2 years ago

First off, thanks for your work on fidget. I've been using it for awhile now on some projects.

I've been trying to use tab in text editable components, but have not found a way to set it. When I explored typography I see that the tab button is not used at all. I'm trying to find out if I am missing a configuration on Fidget that will allow me to access 'tab' or if I should file a bug in typography for an implementation of tab.

My question, am I missing how to use tabs in editable text and if I am can point me in the right direction?

If I am right and tabs are not available can you let me know where I should file a bug? Here or in typography?

I am also willing to contribute to this project and if you need/want help with implementing tab let me know and I can do that.

MorganPeterson commented 2 years ago

I was able to solve this by looking at one of your tests and figuring it out on my own. I will go ahead and close this issue.

Solution for those curious:

 for buttonIdx in 0..<buttonDown.len:
   let button = Button(buttonIdx)
   if buttonDown[button]:
     case button
       of Button.TAB:
         textBox.typeCharacters("    ") # if you want spaces instead of \t
      else:
        discard