(* MathView widget *)
(******************************************************************************)
+let helmns = Gdome.domString "http://www.cs.unibo.it/helm";;
+
+(*
+let choose_selection mmlwidget (element : Gdome.element option) =
+ let module G = Gdome in
+ let rec aux element =
+ if element#hasAttributeNS
+ ~namespaceURI:Misc.helmns
+ ~localName:(G.domString "xref")
+ then
+ mmlwidget#set_selection (Some element)
+ else
+ try
+ match element#get_parentNode with
+ None -> assert false
+ (*CSC: OCAML DIVERGES!
+ | Some p -> aux (new G.element_of_node p)
+ *)
+ | Some p -> aux (new Gdome.element_of_node p)
+ with
+ GdomeInit.DOMCastException _ ->
+ prerr_endline
+ "******* trying to select above the document root ********"
+ in
+ match element with
+ Some x -> aux x
+ | None -> mmlwidget#set_selection None
+;;
+*)
+
(* Callbacks *)
let selection_changed mathview (element : Gdome.element option) =
+ let rec aux element =
+ if element#hasAttributeNS
+ ~namespaceURI:helmns
+ ~localName:(Gdome.domString "xref")
+ then
+ mathview#set_selection (Some element)
+ else
+ try
+ match element#get_parentNode with
+ None -> mathview#set_selection None
+ | Some p -> aux (new Gdome.element_of_node p)
+ with
+ GdomeInit.DOMCastException _ ->
+ prerr_endline "******* trying to select above the document root ********"
+ in
print_endline ("selection_changed: " ^
(match element with
None -> "selection_changed on nothing"
| Some element -> element#get_tagName#to_string
)
) ;
- mathview#set_selection element;
+ match element with
+ None -> ()
+ | Some el -> aux el;
flush stdout
;;
end
| None -> assert false (* every element has a parent *)
-let click mathview (element : Gdome.element) _ =
+let click mathview (element : Gdome.element option) _ =
let module G = Gdome in
- if not (jump element) then
- if not (mathview#action_toggle element) then
- ()
+ match element with
+ None -> print_string "CLICKED ON NOTHING\n" ; flush stdout
+ | Some element ->
+ if not (jump element) then
+ if not (mathview#action_toggle element) then
+ ()
;;