-let clicked mathview (node : Ominidom.o_mDOMNode) =
- let module O = Ominidom in
- if not (jump node) then
- match mathview#get_action with
- Some n ->
- mathview#action_toggle ;
- print_string ("current action selection: " ^
- string_of_int mathview#action_get_selected ^ "\n") ;
- flush stdout ;
- | None ->
- print_string ("mouse is on: " ^
- (match (mathview#get_element : Ominidom.o_mDOMNode option) with
- Some e ->
- (match e#get_name with
- Some x -> x#get_string
- | None -> "no name"
- )
- | None -> "NO ELEMENT!\n"
- ) ^ "\n") ;
- print_string ("clicked: " ^
- (match node#get_name with
- Some x -> x#get_string
- | None -> "no name"
- ) ^ "\n") ;
- flush stdout
-;;
-
-
-let activate_t1 mathview () =
- mathview#set_font_manager_type `font_manager_t1;
- print_string "WIDGET SET WITH T1 FONTS\n" ;
+(* 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
+ )
+ ) ;
+ match element with
+ None -> ()
+ | Some el -> aux el;