brisk
brisk copied to clipboard
UI: TextInput component
Similar to what we have with TextView
, we need a TextInput
component for entering text.
hey! I'd love to take this issue on! I will open a WIP PR tomorrow.
@schinns Awesome! Ping us on discord if you have any questions.
I am sorry I haven't opened a PR yet. It's taking longer than expected to understand how TextInput component should be handled in Brisk.
So far I have outlined:
- [ ] Need to handle
onFocus
andonBlur
- [ ] Need to handle
keyDown
- [ ] Need to be able to update state i.e. SetFocus, UpdateText, Backspace, ClearWord
- [ ] Support Input styling e.g. border, font, color
I have referenced how Input component was implemented in Revery to get an idea of how it might be implemented in Brisk. I have never done any interfacing C with OCaml work (but really intrigued). Will this task require writing some C code?
@schinns Yes, it will require writing Objective C (in 'C-flavored' stub functions). But we already have stubs like BriskStylableText
and BriskTextView
here, they could serve as examples.
Don't worry about the full scope, just start with something very simple and we'll help you ship the rest.
To give you some pointers:
- We probably need a
BriskTextInput.c
file inrenderer-macos/lib/stubs
dir. There we write all the Obj-C functions for creating and manipulating the native element -
BriskTextInput.re
with binding functions inrenderer-macos/lib/bindings
- it's like a dedicated module on the OCaml side with all theexternal
functions and convenience helpers -
TextInput.re
component inrenderer-macos/lib/components
The last one is what will be exposed to users like <TextInput style=[] value="blabla" onChange=(txt)=>setState(txt) />
. Don't forget to 'expose' the modules in Brisk_macos.re
and add the stubs in library's dune
file (list it in c_names
field).
You might want to explore Apple docs on how to create inputs programmatically. @wokalski any other advise?
Thank you for the pointers @rauanmayemir , and that's great to know about exposing the modules— thanks! I will get exploring, and get a WIP PR up soon!