Search in sources :

Example 1 with KeyPressedEvent

use of limelight.ui.events.panel.KeyPressedEvent in project limelight by slagyr.

the class TextInputKeyProcessorTest method altShiftLeftArrowSelectsToEndOfPreviousWordWithSelection.

@Test
public void altShiftLeftArrowSelectsToEndOfPreviousWordWithSelection() {
    setupSingleLine("Here are four words").withCaretAt(0, 9).andSelectionAt(0, 4);
    processor.processKey(new KeyPressedEvent(ALT + SHIFT, KeyEvent.KEY_LEFT, 0), model);
    assertEquals(TextLocation.at(0, 5), model.getCaretLocation());
    assertEquals(TextLocation.at(0, 4), model.getSelectionLocation());
    assertEquals(true, model.isSelectionActivated());
}
Also used : KeyPressedEvent(limelight.ui.events.panel.KeyPressedEvent) Test(org.junit.Test)

Example 2 with KeyPressedEvent

use of limelight.ui.events.panel.KeyPressedEvent in project limelight by slagyr.

the class TextInputKeyProcessorTest method shiftCmdRightArrowSelectsToTheRightEdgeWithSelectionOn.

@Test
public void shiftCmdRightArrowSelectsToTheRightEdgeWithSelectionOn() {
    setupSingleLine("Here are four words").withCaretAt(0, 1).andSelectionAt(0, 4);
    processor.processKey(new KeyPressedEvent(SHIFT + CMD, KeyEvent.KEY_RIGHT, 0), model);
    assertEquals(model.getEndLocation(), model.getCaretLocation());
    assertEquals(TextLocation.at(0, 4), model.getSelectionLocation());
    assertEquals(true, model.isSelectionActivated());
}
Also used : KeyPressedEvent(limelight.ui.events.panel.KeyPressedEvent) Test(org.junit.Test)

Example 3 with KeyPressedEvent

use of limelight.ui.events.panel.KeyPressedEvent in project limelight by slagyr.

the class StageKeyListenerTest method focuedPanelReceivesPressKeyEvents.

@Test
public void focuedPanelReceivesPressKeyEvents() throws Exception {
    panel.getEventHandler().add(KeyPressedEvent.class, action);
    listener.focusOn(panel);
    final KeyEvent pressedEvent = new KeyEvent(component, 1, 2, 3, KeyEvent.VK_A, 'b');
    listener.keyPressed(pressedEvent);
    KeyPressedEvent keyEvent = (KeyPressedEvent) action.event;
    assertSame(panel, keyEvent.getSource());
    assertEquals(limelight.ui.events.panel.KeyEvent.KEY_A, keyEvent.getKeyCode());
}
Also used : KeyEvent(java.awt.event.KeyEvent) KeyPressedEvent(limelight.ui.events.panel.KeyPressedEvent) Test(org.junit.Test)

Example 4 with KeyPressedEvent

use of limelight.ui.events.panel.KeyPressedEvent in project limelight by slagyr.

the class TextInputKeyProcessorTest method altCmdCharacterDoesNothing.

@Test
public void altCmdCharacterDoesNothing() {
    setupSingleLine("Here are four words").withCaretAt(0, 1);
    processor.processKey(new KeyPressedEvent(ALT + CMD, KeyEvent.KEY_A, 0), model);
    assertEquals(TextLocation.at(0, 1), model.getCaretLocation());
    assertEquals(false, model.isSelectionActivated());
}
Also used : KeyPressedEvent(limelight.ui.events.panel.KeyPressedEvent) Test(org.junit.Test)

Example 5 with KeyPressedEvent

use of limelight.ui.events.panel.KeyPressedEvent in project limelight by slagyr.

the class TextInputKeyProcessorTest method cmdDownArrowJumpsToTheEndWithSelection.

@Test
public void cmdDownArrowJumpsToTheEndWithSelection() {
    setupSingleLine("Here are four words").withCaretAt(0, 1).andSelectionAt(0, 4);
    processor.processKey(new KeyPressedEvent(CMD, KeyEvent.KEY_DOWN, 0), model);
    assertEquals(model.getEndLocation(), model.getCaretLocation());
    assertEquals(TextLocation.at(0, 4), model.getSelectionLocation());
    assertEquals(false, model.isSelectionActivated());
}
Also used : KeyPressedEvent(limelight.ui.events.panel.KeyPressedEvent) Test(org.junit.Test)

Aggregations

KeyPressedEvent (limelight.ui.events.panel.KeyPressedEvent)86 Test (org.junit.Test)86 StringSelection (java.awt.datatransfer.StringSelection)2 KeyEvent (java.awt.event.KeyEvent)1