+let rec action mathview (element : Gdome.element) =
+ let module G = Gdome in
+ if element#get_tagName#to_string = "m:maction" then
+ let selection =
+ if element#hasAttribute ~name:(G.domString "selection") then
+ int_of_string (element#getAttribute ~name:(G.domString "selection"))#to_string
+ else
+ 1
+ in
+ mathview#freeze ;
+ (* the widget will cast the index back into a reasonable range *)
+ element#setAttribute ~name:(G.domString "selection") ~value:(G.domString (string_of_int (selection + 1))) ;
+ mathview#thaw ;
+ true
+ else
+ match element#get_parentNode with
+ Some p ->
+ begin
+ try
+ action mathview (new Gdome.element_of_node p)
+ with
+ GdomeInit.DOMCastException _ ->
+ print_string "action: NO MACTION FOUND\n" ;
+ flush stdout ;
+ false
+ end
+ | None -> assert false (* every element has a parent *)
+
+let clicked mathview (element : Gdome.element) =