new H_event()
events.js, line 28
Methods
-
staticH_event.add_event(dom_element, event_name, callback, use_capture){boolean|undefined}
events.js, line 658 -
Adds an event listener to a DOM element.
Handles duplicate prevention and delayed registration.Name Type Description dom_elementHTMLElement Target element. event_namestring Event type. callbackfunction | string Callback function. use_captureboolean optional Use capture phase. Returns:
Type Description boolean | undefined True if added, false if duplicate. -
staticH_event.add_event_click(dom_element, callback, use_capture)
events.js, line 1965 -
Adds a click event listener to a DOM element.
Name Type Description dom_elementHTMLElement The element. callbackfunction Callback function. use_captureboolean optional Use capture phase. -
staticH_event.add_event_click_outside(dom_element, callback, use_capture)
events.js, line 1995 -
Add a click outside event listener to a DOM element.
H_event.other_inside_elements is an array to save other HTMLElement to handle the click like it was inside.
Name Type Description dom_elementHTMLElement The element. callbackfunction Callback function. use_captureboolean | null Use capture phase. -
staticH_event.add_event_dbl_click(dom_element, callback, use_capture)
events.js, line 1975 -
Adds a double-click event listener to a DOM element.
Name Type Description dom_elementHTMLElement The element. callbackfunction Callback function. use_captureboolean optional Use capture phase. -
staticH_event.add_event_delayed(dom_element, event_name, callback, use_capture, delay)
events.js, line 732 -
Adds an event listener with a delay.
Why a delay ? to avoid accident trigerring, if we add event on same dom_element that trigger the add_event.Name Type Description dom_elementHTMLElement Target element. event_namestring Event type. callbackfunction Callback function. use_captureboolean Use capture phase. delaynumber Delay in ms. -
staticH_event.add_event_key(dom_element, callback, use_capture)
events.js, line 1985 -
Adds a keyup event listener to a DOM element.
Name Type Description dom_elementHTMLElement The element. callbackfunction Callback function. use_captureboolean optional Use capture phase. -
staticH_event.add_handler(list, handler)
events.js, line 218 -
Adds a handler to one of the global handler lists.
The list is a property of H_event holding the registered callbacks: window_on_load_handlers or window_on_resize_handlers. A handler already present is refused; a load handler registered once the window is loaded runs immediately instead of being stored.Name Type Description liststring Name of the handler list. handlerfunction | string Handler function, or the name of a global function to register once it exists (a module may not be loaded yet when the name is given). -
staticH_event.add_load_handler(handler)
events.js, line 272 -
Adds a handler to be called on window load.
If the window is already loaded, executes immediately.Name Type Description handlerfunction | string Handler function. -
staticH_event.add_resize_handler(handler)
events.js, line 306 -
Adds a handler to be called on window resize.
Name Type Description handlerfunction | string Handler function -
staticH_event.apply_event(event_name, event, other_event)
events.js, line 746 -
Applies an event to all registered handlers for the event name.
Handles outside events, bubbling, and nested listeners.Name Type Description event_namestring Event type. eventEvent The event. other_eventEvent optional Optional related event. -
staticH_event.broadcast_event(event_name, data, from)
events.js, line 553 -
Broadcasts an event to all listeners.
Optionally restricts to listeners from a specific sender. if from is not specified, all elements listening to an event with the name specified in event_name will be invoked!Name Type Description event_namestring Name of the event. data* Data to send. fromObject optional Sender object (optional). -
staticH_event.check_resize(event){boolean}
events.js, line 1370 -
Checks if the mouse is near a resizable border. Updates resize_data and cursor.
Name Type Description eventEvent The event. Returns:
Type Description boolean True if resize should start. -
staticH_event.confirm_gate(event_name, event){boolean}
events.js, line 923 -
Holds back an event that carries a data-confirm question.
A click or a change on an element owning a data-confirm attribute is stopped here, the question is asked once, and the callbacks of the event are applied only when the user agrees. Any element works this way: a plain button, a div whose click is bound in JavaScript, a select, a checkbox.
A form submit is not concerned: H_validator asks its question once the form is known to be valid, because a confirmation asked here would come before the fields are checked, and a submit sent with the Enter key produces no click at all.
The element must have a listener for the event, so a submit button that carries only data-confirm is left untouched and keeps its confirmation in H_validator.Name Type Description event_namestring Event type. eventEvent The event. Returns:
Type Description boolean True when the event is held back and must not be applied now. -
staticH_event.confirm_revert(dom_element, event_name)
events.js, line 1004 -
Puts a control back on the value it was rendered with, when the user refuses the data-confirm question of a change.
The browser moves a select, a checkbox or a text field before sending the change event, so a refusal has to undo that move by hand. A file field cannot be put back: its choice is lost.Name Type Description dom_elementHTMLElement The control carrying the question. event_namestring Event type: only a change moves a control. -
staticH_event.detect_mouse_buttons(event)
events.js, line 425 -
Detects which mouse buttons are pressed. Updates H_event.mouse state.
Name Type Description eventMouseEvent | PointerEvent The event. -
staticH_event.disable_drag(dom_element)
events.js, line 1596 -
Disables dragging for a DOM element.
Name Type Description dom_elementHTMLElement The element. -
staticH_event.disable_drop(dom_element)
events.js, line 1876 -
Disables drop events on a DOM element.
Name Type Description dom_elementHTMLElement | Document The element or document. -
staticH_event.disable_event_callback(event){boolean}
events.js, line 459 -
Prevents default event behavior.
Name Type Description eventEvent The event. Returns:
Type Description boolean Always false to block callbacks... -
staticH_event.disable_resize(dom_element)
events.js, line 1319 -
Disables resizing for a DOM element.
Name Type Description dom_elementHTMLElement The element. -
staticH_event.disable_scroll_on_touch(event){boolean}
events.js, line 1810 -
Prevents scrolling on touch devices during drag/resize.
actually similar to H_event.prevent_default(), but it was not the case in the past.
so perhaps it will change again in the future...
so keeped for compatibility reason.Name Type Description eventTouchEvent The event. Returns:
Type Description boolean Always false. -
staticH_event.drag(event, b)
events.js, line 1660 -
Handles dragging of a DOM element during mouse move.
Name Type Description eventEvent The event. bboolean Unused. -
staticH_event.drag_end(event)
events.js, line 1766 -
Ends drag operation.
Name Type Description eventEvent The event. -
staticH_event.drag_target(dom_element){HTMLElement|null}
events.js, line 1577 -
Resolves the element a mousedown has to drag.
An element carrying data-draggable is dragged when it is grabbed itself. An element carrying data-drag_anywhere (a window: H_ui_window) is dragged when a non interactive part of it is grabbed - a modal of module has no title bar, and its content covers the whole window. A form control keeps its own behaviour: a drag started on a field must not move the window.Name Type Description dom_elementHTMLElement The mousedown target. Returns:
Type Description HTMLElement | null The element to drag, null if none. -
staticH_event.enable_drag(dom_element, start_handler, move_handler, end_handler, avatar_handler){boolean}
events.js, line 1526 -
Enables dragging for a DOM element.
Sets up handlers and optional avatar to represent the moving element.
all handlers are callbacks to call at each moment of the drag& drop : start, move, end, and can be replaced by null.
the end_handler can used to replace the drop event on the target.Name Type Description dom_elementHTMLElement The element. start_handlerfunction | Object Start handler or settings object. move_handlerfunction Move handler. end_handlerfunction End handler. avatar_handlerfunction | string Avatar handler or string. Returns:
Type Description boolean True if enabled. -
staticH_event.enable_drop(dom_element, callback){boolean}
events.js, line 1844 -
Enables drop events on a DOM element.
Name Type Description dom_elementHTMLElement | Document The element or document. callbackfunction Drop callback. Returns:
Type Description boolean True if enabled. -
staticH_event.enable_resize(dom_element, start_resize_handler, resize_handler, end_resize_handler, border_detection_size)
events.js, line 1300 -
Enables resizing for a DOM element.
By default, the border detection size is 10 px, and you can use the right and bottom border to resize.
It's better practice to display this border, and set the overflow style property of the dom element to hidden
Sets up handlers and border detection.Name Type Default Description dom_elementHTMLElement The element. start_resize_handlerfunction null Start handler. resize_handlerfunction null Resize handler. end_resize_handlerfunction null End handler. border_detection_sizenumber 10 optional Border size in px. -
staticH_event.end_global_move(event)
events.js, line 1246 -
Ends global move tracking for drag/resize.
Name Type Description eventEvent The event. -
staticH_event.end_resize(event)
events.js, line 1458 -
Ends resize operation.
Name Type Description eventEvent The event. -
staticH_event.extract_data_from_drop_event(event, filter){Object}
events.js, line 1911 -
Extracts data from a drop event.
Supports files, HTML, and text.Name Type Description eventDragEvent | CustomEvent The event. filterArray optional Types to filter. Returns:
Type Description Object Extracted data. -
staticH_event.global_drop(event)
events.js, line 1828 -
Handles global drop events.
Calls the default drop callback if set.Name Type Description eventDragEvent | CustomEvent The event. -
staticH_event.global_key_down(event)
events.js, line 337 -
Handles global keydown events.
Updates key state and applies EVENT_KEYDOWN.Name Type Description eventKeyboardEvent The keydown event. -
staticH_event.global_key_up(event)
events.js, line 355 -
Handles global keyup events.
Updates key state and applies EVENT_KEYUP.Name Type Description eventKeyboardEvent The keyup event. -
staticH_event.global_mouse_down(event)
events.js, line 373 -
Handles global mousedown or pointerdown events.
Detects mouse buttons, initializes drag/resize, and applies EVENT_MOUSEDOWN.Name Type Description eventMouseEvent | PointerEvent The event. -
staticH_event.global_mouse_move(event)
events.js, line 1149 -
Handles global mouse or pointer move events.
Updates drag/resize state and triggers mouse enter/leave.Name Type Description eventMouseEvent | PointerEvent The event. -
staticH_event.global_mouse_up(event)
events.js, line 469 -
Handles global mouseup or pointerup events.
Detects clicks end, double clicks end, and applies EVENT_MOUSEUP.Name Type Description eventMouseEvent | PointerEvent The event. -
staticH_event.handler_event(event)
events.js, line 720 -
Internal event handler that applies the event to registered callbacks.
Name Type Description eventEvent The event. -
staticH_event.has_drag(dom_element){boolean}
events.js, line 1561 -
Checks if a DOM element has drag enabled.
Name Type Description dom_elementHTMLElement The element. Returns:
Type Description boolean True if draggable. -
staticH_event.has_drop(dom_element){boolean|number}
events.js, line 1894 -
Checks if a DOM element has drop enabled.
Name Type Description dom_elementHTMLElement | Document The element or document. Returns:
Type Description boolean | number True/1 if enabled, 0 if not. -
staticH_event.has_event(dom_element, event_name){boolean}
events.js, line 873 -
Checks if a DOM element has a listener for a specific event.
Name Type Description dom_elementHTMLElement The element. event_namestring Event type. Returns:
Type Description boolean True if found. -
staticH_event.has_event_callback(dom_element, event_name, callback){boolean}
events.js, line 894 -
Checks if a DOM element has a specific callback for an event.
Name Type Description dom_elementHTMLElement The element. event_namestring Event type. callbackfunction Callback function. Returns:
Type Description boolean True if found. -
staticH_event.init()
events.js, line 176 -
Initializes global event listeners for mouse, touch, keyboard, resize, and load events.
Detects platform and sets up appropriate handlers. -
staticH_event.init_drag(dom_element)
events.js, line 1629 -
Initializes drag operation for a DOM element.
launched by global_mouse_downName Type Description dom_elementHTMLElement The element. -
staticH_event.init_mouse_down_event(event)
events.js, line 435 -
Initializes the current mousedown event and computes offsets.
Name Type Description eventMouseEvent | PointerEvent The event. -
staticH_event.init_resize(mouse_down_event){boolean}
events.js, line 1339 -
Initializes resize operation.
launched by global_mouse_downName Type Description mouse_down_eventEvent The mousedown event. Returns:
Type Description boolean True if resize started. -
staticH_event.is_resizable(dom_element){boolean}
events.js, line 1329 -
Checks if a DOM element is resizable.
Name Type Description dom_elementHTMLElement The element. Returns:
Type Description boolean True if resizable. -
staticH_event.is_submit_control(dom_element){boolean}
events.js, line 980 -
Tells whether a click on an element submits a form, i.e. whether its question belongs to H_validator rather than to the gate.
A `Name Type Description dom_elementHTMLElement The element. Returns:
Type Description boolean True when a click on it leads to the submit of a form. -
staticH_event.listen_to_event(to, event_name, callback, from)
events.js, line 585 -
Registers a listener for an event.
Optionally restricts to events from a specific sender.
if from is not specified, all elements listening to an event with the name specified in event_name will be invoked.Name Type Description toObject Target object. event_namestring Name of the event. callbackfunction Callback function. fromObject optional Sender object (optional). -
staticH_event.mouse_interacting(){boolean}
events.js, line 297 -
Returns true if mouse is interacting (dragging, resizing, etc).
Returns:
Type Description boolean True if interacting. -
staticH_event.prevent_default(event)
events.js, line 1283 -
Prevents default event behavior only.
Name Type Description eventEvent The event. -
staticH_event.remove_all_events(dom_element){boolean}
events.js, line 1090 -
Removes all event listeners from a DOM element.
Name Type Description dom_elementHTMLElement The element. Returns:
Type Description boolean True if removed. -
staticH_event.remove_event(dom_element, event_name, callback){boolean}
events.js, line 1042 -
Removes a specific event listener from a DOM element.
Name Type Description dom_elementHTMLElement The element. event_namestring Event type. callbackfunction Callback function. Returns:
Type Description boolean True if removed. -
staticH_event.remove_event_click(dom_element, callback)
events.js, line 2006 -
Removes a click event listener from a DOM element.
Name Type Description dom_elementHTMLElement The element. callbackfunction Callback function. -
staticH_event.remove_event_click_outside(dom_element, callback)
events.js, line 2033 -
Removes a click outside event listener from a DOM element.
Name Type Description dom_elementHTMLElement The element. callbackfunction Callback function. -
staticH_event.remove_event_dbl_click(dom_element, callback)
events.js, line 2015 -
Removes a double-click event listener from a DOM element.
Name Type Description dom_elementHTMLElement The element. callbackfunction Callback function. -
staticH_event.remove_event_key(dom_element, callback)
events.js, line 2024 -
Removes a keyup event listener from a DOM element.
Name Type Description dom_elementHTMLElement The element. callbackfunction Callback function. -
staticH_event.remove_handler(list, handler)
events.js, line 243 -
Removes a handler from one of the global handler lists.
Name Type Description liststring Name of the handler list. handlerfunction Handler to remove. -
staticH_event.remove_load_handler(handler)
events.js, line 280 -
Removes a handler from the window load handlers list.
Name Type Description handlerfunction Handler to remove. -
staticH_event.remove_resize_handler(handler)
events.js, line 315 -
Removes a handler from the window resize handlers list.
Name Type Description handlerfunction Handler to remove. -
staticH_event.resize(event)
events.js, line 1470 -
Handles resizing of a DOM element during mouse move.
Name Type Description eventEvent The event. -
staticH_event.run_handlers(list)
events.js, line 256 -
Executes every handler of one of the global handler lists.
Name Type Description liststring Name of the handler list. -
staticH_event.send_event(dom_element, type, data, bubbles, cancelable)
events.js, line 617 -
Dispatches a DOM or custom event on an element.
Name Type Default Description dom_elementHTMLElement Target element. typestring Event type. data* optional Event detail data. bubblesboolean true optional Whether the event bubbles. cancelableboolean true optional Whether the event is cancelable. -
staticH_event.send_event_click(dom_element, data, bubbles, cancelable)
events.js, line 2047 -
Dispatches a click event on a DOM element.
Name Type Description dom_elementHTMLElement The element. data* optional Event detail data. bubblesboolean optional Whether the event bubbles. cancelableboolean optional Whether the event is cancelable. -
staticH_event.send_event_click_outside(dom_element, data, bubbles, cancelable)
events.js, line 2080 -
Dispatches a click outside event on a DOM element.
Name Type Description dom_elementHTMLElement The element. data* optional Event detail data. bubblesboolean optional Whether the event bubbles. cancelableboolean optional Whether the event is cancelable. -
staticH_event.send_event_dbl_click(dom_element, data, bubbles, cancelable)
events.js, line 2058 -
Dispatches a double-click event on a DOM element.
Name Type Description dom_elementHTMLElement The element. data* optional Event detail data. bubblesboolean optional Whether the event bubbles. cancelableboolean optional Whether the event is cancelable. -
staticH_event.send_event_key(dom_element, data, bubbles, cancelable)
events.js, line 2069 -
Dispatches a keyup event on a DOM element.
Name Type Description dom_elementHTMLElement The element. data* optional Event detail data. bubblesboolean optional Whether the event bubbles. cancelableboolean optional Whether the event is cancelable. -
staticH_event.set_default_drop_callback(callback)
events.js, line 1820 -
Sets the default drop callback for drag-and-drop.
Name Type Description callbackfunction Callback function. -
staticH_event.set_drag_area(dom_element, area_dom_element, padding)
events.js, line 1606 -
Sets a drag area dom element for a DOM element.
Name Type Default Description dom_elementHTMLElement The element. area_dom_elementHTMLElement Area element. paddingnumber 0 optional Padding in px. -
staticH_event.start_global_move(dom_element, move_handler, end_move_handler)
events.js, line 1129 -
Starts tracking global mouse/touch movement for drag/resize.
Name Type Description dom_elementHTMLElement Target element. move_handlerfunction Move handler. end_move_handlerfunction End handler. -
staticH_event.stop_event(event){boolean}
events.js, line 1262 -
Stops event propagation and default behavior.
Name Type Description eventEvent The event. Returns:
Type Description boolean Always false. -
staticH_event.unset_drag_area(dom_element)
events.js, line 1618 -
Unsets the drag area for a DOM element.
Name Type Description dom_elementHTMLElement The element. -
staticH_event.window_load(event)
events.js, line 289 -
Executes all registered window load handlers.
Sets window_loaded to true.Name Type Description eventEvent The load event. -
staticH_event.window_resize(event)
events.js, line 324 -
Executes all registered window resize handlers.
Also marks the body rect as dirty.Name Type Description eventEvent The resize event.