void CreationTool::on_pressed(QPointF scene, Scenario::Point sp) { mapTopItem(itemUnderMouse(scene), // Press a state [&] (const Id<StateModel>& id) { localSM().postEvent(new ClickOnState_Event{id, sp}); }, // Press an event [&] (const Id<EventModel>& id) { localSM().postEvent(new ClickOnEvent_Event{id, sp}); }, // Press a TimeNode [&] (const Id<TimeNodeModel>& id) { localSM().postEvent(new ClickOnTimeNode_Event{id, sp}); }, // Press a Constraint [&] (const Id<ConstraintModel>&) { }, // Press a slot handle [&] (const SlotModel&) { }, // Click on the background [&] () { // Here we have the logic for the creation in nothing // where we instead choose the latest state if selected if(auto state = furthestSelectedState(m_parentSM.model())) { if(m_parentSM.model().events.at(state->eventId()).date() < sp.date) { localSM().postEvent(new ClickOnState_Event{ state->id(), sp}); return; } } localSM().postEvent(new ClickOnNothing_Event{sp}); }); }
void Menu::mouseClick() { if( itemUnderMouse() ) chooseItem(); }
void Menu::mouseMove() { size_t item_offset = itemUnderMouse(); if( item_offset < m_items.size() ) setFocusToPosition( item_offset ); }