File tree Expand file tree Collapse file tree 3 files changed +16
-6
lines changed Expand file tree Collapse file tree 3 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -143,16 +143,25 @@ let confirm ~title ?(ok_label=[%i"OK"]) ?(cancel_label=[%i"Cancel"]) contents f
143143 close_button cancel_label;
144144 ]
145145
146- let ask_string ~title ?(ok_label =[% i" OK" ]) contents =
146+ let ask_string ~title ?(ok_label =[% i" OK" ]) ?( may_cancel = true ) contents =
147147 let input_field =
148148 H. input ~a: [
149149 H. a_input_type `Text ;
150150 ] ()
151151 in
152152 let result_t, up = Lwt. wait () in
153- ext_alert ~title (contents @ [input_field]) ~buttons: [
154- box_button ok_label (fun () -> Lwt. wakeup up @@ Manip. value input_field)
155- ];
153+ let validate _ =
154+ Lwt. wakeup up @@ Manip. value input_field
155+ in
156+ Manip.Ev. onreturn input_field validate;
157+ let buttons =
158+ box_button ok_label validate
159+ :: (if may_cancel
160+ then [close_button [% i" Cancel" ]]
161+ else [] )
162+ in
163+ ext_alert ~title (contents @ [input_field]) ~buttons ;
164+ Manip. focus input_field;
156165 result_t
157166
158167let default_exn_printer = function
@@ -1157,7 +1166,7 @@ let get_token ?(has_server = true) () =
11571166 Lwt. return
11581167 with
11591168 Not_found ->
1160- ask_string ~title: " Token"
1169+ ask_string ~title: " Token" ~may_cancel: false
11611170 [H. txt [% i" Enter your token" ]]
11621171 >> = fun input_tok ->
11631172 let token = Token. parse (input_tok) in
Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ val confirm :
4545val ask_string :
4646 title : string ->
4747 ?ok_label : string ->
48+ ?may_cancel : bool ->
4849 [< Html_types .div_content > `Input ] Tyxml_js.Html .elt list ->
4950 string Lwt .t
5051
Original file line number Diff line number Diff line change @@ -211,7 +211,7 @@ let rec teacher_tab token _select _params () =
211211 in
212212 let open_partition_ () =
213213 Lwt. async (fun () ->
214- ask_string ~title: " Choose a function name "
214+ ask_string ~title: " Partitioning of student solutions "
215215 [H. txt @@ " Choose a function name to partition codes from " ^ id ^ " : " ]
216216 > |= fun funname ->
217217 let _win =
You can’t perform that action at this time.
0 commit comments