2002-04-26 05:16:26 -07:00
|
|
|
##ifdef CAMLTK
|
|
|
|
|
|
|
|
let bind widget tag eventsequence action =
|
|
|
|
tkCommand [|
|
|
|
|
cCAMLtoTKwidget widget_canvas_table widget;
|
|
|
|
TkToken "bind";
|
|
|
|
cCAMLtoTKtagOrId tag;
|
|
|
|
cCAMLtoTKeventSequence eventsequence;
|
|
|
|
begin match action with
|
|
|
|
| BindRemove -> TkToken ""
|
|
|
|
| BindSet (what, f) ->
|
2002-07-23 07:12:03 -07:00
|
|
|
let cbId = register_callback widget (wrapeventInfo f what) in
|
|
|
|
TkToken ("camlcb " ^ cbId ^ (writeeventField what))
|
2002-04-26 05:16:26 -07:00
|
|
|
| BindSetBreakable (what, f) ->
|
2002-07-23 07:12:03 -07:00
|
|
|
let cbId = register_callback widget (wrapeventInfo f what) in
|
|
|
|
TkToken ("camlcb " ^ cbId ^ (writeeventField what)^
|
|
|
|
" ; if { $BreakBindingsSequence == 1 } then { break ;} ; \
|
|
|
|
set BreakBindingsSequence 0")
|
2002-04-26 05:16:26 -07:00
|
|
|
| BindExtend (what, f) ->
|
2002-07-23 07:12:03 -07:00
|
|
|
let cbId = register_callback widget (wrapeventInfo f what) in
|
|
|
|
TkToken ("+camlcb " ^ cbId ^ (writeeventField what))
|
2002-04-26 05:16:26 -07:00
|
|
|
end
|
|
|
|
|]
|
|
|
|
;;
|
|
|
|
|
|
|
|
##else
|
|
|
|
|
2000-04-12 18:11:06 -07:00
|
|
|
let bind ~events
|
2000-04-11 20:43:25 -07:00
|
|
|
?(extend = false) ?(breakable = false) ?(fields = [])
|
2000-04-12 18:11:06 -07:00
|
|
|
?action widget tag =
|
2000-02-15 02:10:26 -08:00
|
|
|
tkCommand
|
|
|
|
[| cCAMLtoTKwidget widget;
|
|
|
|
TkToken "bind";
|
|
|
|
cCAMLtoTKtagOrId tag;
|
|
|
|
cCAMLtoTKeventSequence events;
|
|
|
|
begin match action with None -> TkToken ""
|
|
|
|
| Some f ->
|
|
|
|
let cbId =
|
2000-04-11 20:43:25 -07:00
|
|
|
register_callback widget ~callback: (wrapeventInfo f fields) in
|
2000-02-15 02:10:26 -08:00
|
|
|
let cb = if extend then "+camlcb " else "camlcb " in
|
|
|
|
let cb = cb ^ cbId ^ writeeventField fields in
|
|
|
|
let cb =
|
|
|
|
if breakable then
|
|
|
|
cb ^ " ; if { $BreakBindingsSequence == 1 } then { break ;}"
|
|
|
|
^ " ; set BreakBindingsSequence 0"
|
|
|
|
else cb in
|
|
|
|
TkToken cb
|
|
|
|
end
|
|
|
|
|]
|
2002-04-26 05:16:26 -07:00
|
|
|
;;
|
|
|
|
|
|
|
|
##endif
|