5 | BindSet of eventField list * (eventInfo -> unit)
6 | BindSetBreakable of eventField list * (eventInfo -> unit)
8 | BindExtend of eventField list * (eventInfo -> unit)
14 widget -> (modifier list * xEvent) list -> bindAction -> unit
17 let bind widget eventsequence action =
18 tkCommand [| TkToken "bind";
19 TkToken (Widget.name widget);
20 cCAMLtoTKeventSequence eventsequence;
21 begin match action with
22 BindRemove -> TkToken ""
23 | BindSet (what, f) ->
24 let cbId = register_callback widget (wrapeventInfo f what)
26 TkToken ("camlcb " ^ cbId ^ (writeeventField what))
27 | BindSetBreakable (what, f) ->
28 let cbId = register_callback widget (wrapeventInfo f what)
30 TkToken ("camlcb " ^ cbId ^ (writeeventField what) ^
31 " ; if { $BreakBindingsSequence == 1 } then { break ;} ; set BreakBindingsSequence 0")
32 | BindExtend (what, f) ->
33 let cbId = register_callback widget (wrapeventInfo f what)
35 TkToken ("+camlcb " ^ cbId ^ (writeeventField what))
42 string -> (modifier list * xEvent) list -> bindAction -> unit
44 /FUNCTION class arg is not constrained *)
46 let bind_class clas eventsequence action =
47 tkCommand [| TkToken "bind";
49 cCAMLtoTKeventSequence eventsequence;
50 begin match action with
51 BindRemove -> TkToken ""
52 | BindSet (what, f) ->
53 let cbId = register_callback Widget.dummy
54 (wrapeventInfo f what) in
55 TkToken ("camlcb " ^ cbId ^ (writeeventField what))
56 | BindSetBreakable (what, f) ->
57 let cbId = register_callback Widget.dummy
58 (wrapeventInfo f what) in
59 TkToken ("camlcb " ^ cbId ^ (writeeventField what)^
60 " ; if { $BreakBindingsSequence == 1 } then { break ;} ; set BreakBindingsSequence 0" )
61 | BindExtend (what, f) ->
62 let cbId = register_callback Widget.dummy
63 (wrapeventInfo f what) in
64 TkToken ("+camlcb " ^ cbId ^ (writeeventField what))
71 string -> (modifier list * xEvent) list -> bindAction -> unit
75 let bind_tag = bind_class
80 val break : unit -> unit
83 let break = function () ->
84 Textvariable.set (Textvariable.coerce "BreakBindingsSequence") "1"
87 (* Legacy functions *)
88 let tag_bind = bind_tag;;
89 let class_bind = bind_class;;
93 let bind_class ~events ?(extend = false) ?(breakable = false) ?(fields = [])
94 ?action ?on:widget name =
95 let widget = match widget with None -> Widget.dummy | Some w -> coe w in
99 cCAMLtoTKeventSequence events;
100 begin match action with None -> TkToken ""
103 register_callback widget ~callback: (wrapeventInfo f fields) in
104 let cb = if extend then "+camlcb " else "camlcb " in
105 let cb = cb ^ cbId ^ writeeventField fields in
108 cb ^ " ; if { $BreakBindingsSequence == 1 } then { break ;}"
109 ^ " ; set BreakBindingsSequence 0"
116 let bind ~events ?extend ?breakable ?fields ?action widget =
117 bind_class ~events ?extend ?breakable ?fields ?action ~on:widget
121 let bind_tag = bind_class
126 val break : unit -> unit
129 let break = function () ->
130 tkCommand [| TkToken "set" ; TkToken "BreakBindingsSequence" ; TkToken "1" |]