Search in sources :

Example 1 with Event

use of limelight.events.Event in project limelight by slagyr.

the class DropDownPopup method createListItems.

private void createListItems() {
    EventAction itemChosenAction = new EventAction() {

        public void invoke(Event e) {
            PanelEvent event = (PanelEvent) e;
            choose((PropPanel) event.getRecipient());
        }
    };
    EventAction itemSelectedAction = new EventAction() {

        public void invoke(Event e) {
            PanelEvent event = (PanelEvent) e;
            select((PropPanel) event.getRecipient());
        }
    };
    for (Object option : dropDown.getChoices()) {
        PropPanel listItem = new PropPanel(new SimplePropProxy(), Util.toMap("name", "limelight_builtin_drop_down_popup_list_item"));
        listItem.getStyle().addExtension(stylesStore.get("limelight_builtin_drop_down_popup_list_item"));
        listItem.getEventHandler().add(MouseClickedEvent.class, itemChosenAction);
        listItem.getEventHandler().add(MouseEnteredEvent.class, itemSelectedAction);
        listItem.setText(option.toString());
        if (option.equals(dropDown.getSelectedChoice()))
            select(listItem);
        popupList.add(listItem);
    }
}
Also used : PanelEvent(limelight.ui.events.panel.PanelEvent) PropPanel(limelight.ui.model.PropPanel) SimplePropProxy(limelight.ui.SimplePropProxy) EventAction(limelight.events.EventAction) PanelEvent(limelight.ui.events.panel.PanelEvent) Event(limelight.events.Event) MouseEnteredEvent(limelight.ui.events.panel.MouseEnteredEvent) MouseClickedEvent(limelight.ui.events.panel.MouseClickedEvent)

Example 2 with Event

use of limelight.events.Event in project limelight by slagyr.

the class DropDownPopup method createCurtains.

private void createCurtains() {
    curtains = new PropPanel(new SimplePropProxy(), Util.toMap("name", "limelight_builtin_curtains"));
    curtains.getStyle().addExtension(stylesStore.get("limelight_builtin_curtains"));
    curtains.getEventHandler().add(MouseClickedEvent.class, new EventAction() {

        public void invoke(Event event) {
            close();
        }
    });
}
Also used : PropPanel(limelight.ui.model.PropPanel) SimplePropProxy(limelight.ui.SimplePropProxy) EventAction(limelight.events.EventAction) PanelEvent(limelight.ui.events.panel.PanelEvent) Event(limelight.events.Event) MouseEnteredEvent(limelight.ui.events.panel.MouseEnteredEvent) MouseClickedEvent(limelight.ui.events.panel.MouseClickedEvent)

Example 3 with Event

use of limelight.events.Event in project limelight by slagyr.

the class DropDownPopup method createList.

private void createList() {
    popupList = new PropPanel(new SimplePropProxy(), Util.toMap("name", "limelight_builtin_drop_down_popup_list"));
    popupList.getStyle().addExtension(stylesStore.get("limelight_builtin_drop_down_popup_list"));
    popupList.getStyle().setX(dropDown.getParent().getAbsoluteLocation().x - dropDown.getRoot().getX());
    popupList.getStyle().setY(dropDown.getParent().getAbsoluteLocation().y - dropDown.getRoot().getY());
    popupList.getStyle().setWidth(dropDown.getParent().getWidth());
    popupList.getEventHandler().add(MouseClickedEvent.class, new EventAction() {

        public void invoke(Event event) {
        // eat the event so the curtains won't get it
        }
    });
}
Also used : PropPanel(limelight.ui.model.PropPanel) SimplePropProxy(limelight.ui.SimplePropProxy) EventAction(limelight.events.EventAction) PanelEvent(limelight.ui.events.panel.PanelEvent) Event(limelight.events.Event) MouseEnteredEvent(limelight.ui.events.panel.MouseEnteredEvent) MouseClickedEvent(limelight.ui.events.panel.MouseClickedEvent)

Example 4 with Event

use of limelight.events.Event in project limelight by slagyr.

the class PanelEventTest method theRecipientIsSetOnlyDuringDispatchAndThenRestored.

@Test
public void theRecipientIsSetOnlyDuringDispatchAndThenRestored() throws Exception {
    TestablePanelBase recipient = new TestablePanelBase();
    recipient.getEventHandler().add(TestableEvent.class, new EventAction() {

        public void invoke(Event event) {
            dispatchedRecipient = ((PanelEvent) event).getRecipient();
        }
    });
    event.dispatch(recipient);
    assertEquals(recipient, dispatchedRecipient);
    assertEquals(source, event.getRecipient());
}
Also used : MockEventAction(limelight.ui.model.inputs.MockEventAction) EventAction(limelight.events.EventAction) Event(limelight.events.Event) TestablePanelBase(limelight.ui.model.TestablePanelBase) Test(org.junit.Test)

Aggregations

Event (limelight.events.Event)4 EventAction (limelight.events.EventAction)4 SimplePropProxy (limelight.ui.SimplePropProxy)3 MouseClickedEvent (limelight.ui.events.panel.MouseClickedEvent)3 MouseEnteredEvent (limelight.ui.events.panel.MouseEnteredEvent)3 PanelEvent (limelight.ui.events.panel.PanelEvent)3 PropPanel (limelight.ui.model.PropPanel)3 TestablePanelBase (limelight.ui.model.TestablePanelBase)1 MockEventAction (limelight.ui.model.inputs.MockEventAction)1 Test (org.junit.Test)1