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
I am trying to make the cursor move to the next line in a text input.
For that, on shift+enter keyboard presses, I use Widget.set_text and the "\r\n" escape seq.
After hitting shift+enter, the cursor disappear from the screen, but the TextInput widget does not seem to lose the focus.
Here is a small example:
let main () =
let input = W.text_input ~max_size:200 ~prompt:"Enter your name" () in
let label = W.label ~size:40 "Hello!" in
let layout =
L.tower [ L.resident ~w:400 ~h:400 input; L.resident ~w:400 ~h:200 label ]
in
let action ti l ev =
let open Tsdl.Sdl in
let () =
match Trigger.event_kind ev with
| `Key_down
when Event.(get ev keyboard_keycode) = K.return
&& Event.(get ev keyboard_keymod) land Kmod.shift <> 0 ->
W.set_text ti (W.get_text ti ^ "\r\n");
W.update ti
| _ -> ()
in
W.set_text l ("Hello " ^ W.get_text ti ^ "!")
in
let c = W.connect input label action Trigger.[ text_input; key_down ] in
let board = Bogue.of_layout ~connections:[ c ] layout in
Bogue.run board
The text was updated successfully, but these errors were encountered:
Hello !
I am trying to make the cursor move to the next line in a text input.
For that, on shift+enter keyboard presses, I use
Widget.set_text
and the "\r\n" escape seq.After hitting shift+enter, the cursor disappear from the screen, but the
TextInput
widget does not seem to lose the focus.Here is a small example:
The text was updated successfully, but these errors were encountered: