Lomse library. API documentation  0.30.0
EventMouse Class Reference

#include <lomse_events.h>

Inheritance diagram for EventMouse:
EventAction EventInfo

Detailed Description

EventMouse is an object holding information about a mouse interaction. The event type informs about the specific interaction.

Operating system raw mouse events should be passed to Lomse to be processed by the currently selected Task object (see Task objects). Once done, Lomse will generate relevant events of different type (normally EventMouse, EventControlPointMoved and EventUpdateUI events) with relevant information about affected Document objects or other. For instance, a mouse click interpreted as a 'select object' action will generate a EventUpdateUI event; or a mouse move could be interpreted as a View drag operation and will produce a change in the viewport origin and a EventPaint event for repainting the View.

In particular, EventMouse events generation and suggested processing is as follows:

Types k_mouse_in_event and k_mouse_out_event

They are generated in the following situations:

  • TaskOnlyClicks selected: Move mouse generates mouse-in-out events as mouse flies over the different box areas. Probably your application should ignore these events.
  • TaskSelection selected: As mouse moves without clicking EventMouse of types k_mouse_in_event & k_mouse_out_event are generated as mouse flies over the different box areas. Probably your application should ignore these events.
  • TaskDataEntry selected: As mouse moves, mouse in and out events are generated, as mouse flies over the different box areas. Your application can handle these events and react to them as convenient (e.g., highlighting the implied insertion point/area).

Type k_on_click_event

They are generated in the following situations:

  • TaskOnlyClicks selected: When mouse left click at any point, except on Document controls (buttons, link, etc.). Probably your application should ignore these events.
  • TaskSelection selected: Left click down generates on-click event, to initiate selection process and ask your application to take the relevant decisions about how to continue the selection operation. When processing this event, your application should:
    • switch to TaskSelectionRectangle, or
    • switch to task TaskSelectText, or
    • select the clicked object and switch to TaskMoveObject. Remember that to switch Task you have to invoke method Interactor::switch_task().
  • TaskDataEntry selected: When mouse left click. This tasks is oriented to inserting new objects in the Document by clicking with the mouse. User moves the mouse and clicks at insertion point. Your application should determine the type of object to insert based on the application active tool and issue an edition command for inserting the object at the position implied by the event click point.

Type k_link_clicked_event

This event type is generated to inform about a left mouse click on a link (ImoLink) object.

This event is generated when an EventMouse of type k_on_click_event is being processing by Lomse to determine possible actions to do before passing the event to the user application. When Lomse determines that it is a left click on an ImoLink object, the event is passed to the user as an event of type k_link_clicked_event instead of a generic k_on_click_event.

Note
  • Notice that an ImoLink object is different from an hyperlink control (an ImoControl containing an HyperlinkCtrl object). Hyperlink controls are only used in user applications that generate dynamic content (user defined GUI control objects embedded in the Document) and can not be created from files.
  • A link (ImoLink) is only generated by a LMD <link> tag. Therefore, your application will never receive events of this type when processing MusicXML or LDP files.

Type k_show_contextual_menu_event

An EventMouse of type k_show_contextual_menu_event informs about a mouse right button click on an ImoObj that has been interpreted by Lomse as a request for displaying its contextual menu (it is up to your application the decide what is this menu, if any, and what to do whit this event).

They are generated in the following situations:

  • TaskSelection selected: Right click down, selects object and sends EventUpdateUI event (in case your application would like to enable/disable tools), then sends a EventMouse (k_show_contextual_menu_event) to request to show the contextual menu associated to the selected object, if any.
  • TaskDataEntry selected: Right click sends a EventMouse (k_show_contextual_menu_event) to request to show the contextual menu associated to the pointed object, if any.

Public Member Functions

 EventMouse (EEventType type, WpInteractor wpInteractor, ImoId id, Pixels x, Pixels y, unsigned flags, WpDocument wpDoc)
 
ImoObj * get_imo_object ()
 
Observableget_source () override
 
ImoId get_imo_id ()
 
Pixels get_x ()
 
Pixels get_y ()
 
unsigned get_flags ()
 
- Public Member Functions inherited from EventAction
virtual ~EventAction ()
 
WpInteractor get_interactor ()
 
WpDocument get_document ()
 
bool is_still_valid ()
 
- Public Member Functions inherited from EventInfo
virtual ~EventInfo ()
 
EEventType get_event_type ()
 
bool is_doc_modified_event ()
 
bool is_update_window_event ()
 
bool is_mouse_in_event ()
 
bool is_mouse_out_event ()
 
bool is_on_click_event ()
 
bool is_link_clicked_event ()
 
bool is_show_contextual_menu_event ()
 
bool is_control_point_moved_event ()
 
bool is_selection_set_change ()
 
bool is_pointed_object_change ()
 
bool is_do_play_score_event ()
 
bool is_pause_score_event ()
 
bool is_stop_playback_event ()
 
bool is_tracking_event ()
 
bool is_update_viewport_event ()
 
bool is_end_of_playback_event ()
 

Constructor & Destructor Documentation

◆ EventMouse()

EventMouse::EventMouse ( EEventType  type,
WpInteractor  wpInteractor,
ImoId  id,
Pixels  x,
Pixels  y,
unsigned  flags,
WpDocument  wpDoc 
)
inline

Constructor.

Member Function Documentation

◆ get_flags()

unsigned EventMouse::get_flags ( )
inline

Returns a set of flags signaling the conditions at which the event took place. The different flags are described by enum EEventFlag

◆ get_imo_id()

ImoId EventMouse::get_imo_id ( )
inline

Returns the ID of the Document object (ImoObj) affected by the event. For instance, for a mouse click event this object will be the ID of the ImoObj pointed by the mouse.

◆ get_imo_object()

ImoObj* EventMouse::get_imo_object ( )

Returns a pointer to the Document object (ImoObj) affected by the event. For instance, for a mouse click event this object will be the ImoObj pointed by the mouse.

◆ get_source()

Observable* EventMouse::get_source ( )
overridevirtual

Returns a pointer to the Observable object (an ImoContentObj) related to the event. It is either the mouse pointed object or the first ancestor of type ImoContentObj in the internal model hierarchy.

Reimplemented from EventInfo.

◆ get_x()

Pixels EventMouse::get_x ( )
inline

Returns the x coordinate (pixels relative to viewport origin) at which the event took place.

◆ get_y()

Pixels EventMouse::get_y ( )
inline

Returns the y coordinate (pixels relative to viewport origin) at which the event took place.