Changeset 1836


Ignore:
Timestamp:
11/27/14 15:37:58 (9 years ago)
Author:
dmay
Message:

handle text input events by splitting them into separate key events again

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-plugin-jfc/src/main/java/de/ugoe/cs/autoquest/plugin/jfc/commands/CMDgenerateJacaretoReplay.java

    r1834 r1836  
    3232import java.util.UUID; 
    3333import java.util.logging.Level; 
     34 
     35import javax.swing.UIManager; 
    3436 
    3537import de.ugoe.cs.autoquest.CommandHelpers; 
     
    227229        ); 
    228230        writeLine(writer, 
    229                   "<SystemInfo procTime=\"0\" duration=\"0\" screenWidth=\"2646\" screenHeight=\"1024\" javaVersion=\"1.7.0_65\" lookAndFeel=\"javax.swing.plaf.metal.MetalLookAndFeel\" uuid=\"720f430f-52cf-4d8b-9fbe-58434f766efe\" />"); 
     231                  "<SystemInfo procTime=\"0\" duration=\"0\" screenWidth=\"2646\" screenHeight=\"1024\" javaVersion=\"1.7.0_65\" " 
     232                  + "lookAndFeel=\"" + UIManager.getLookAndFeel().getClass().getName() + "\" " 
     233                  + "uuid=\"720f430f-52cf-4d8b-9fbe-58434f766efe\" />"); 
    230234        writeLine(writer, 
    231235                  "<KeyboardState procTime=\"0\" duration=\"0\" isNumLockOn=\"false\" isScrollLockOn=\"false\" isCapsLockOn=\"false\" applyIsNumLockOn=\"true\" applyIsScrollLockOn=\"true\" applyIsCapsLockOn=\"true\" uuid=\"28146f79-9fc7-49f9-b4a8-5866a7625683\" />"); 
     
    300304                } 
    301305                else if (event.getType() instanceof MouseClick) { 
    302                     // if a menu file was provided, use the improved event 
    303                     // generation 
    304                     // TODO: check how much of this is still necessary with 
    305                     // the new menu index system 
    306                     if (menuList != null) { 
    307                         if (event.getTarget() instanceof JFCMenuButton) { 
     306                    if (event.getTarget() instanceof JFCMenuButton) { 
     307                        // if a menu file was provided, use the improved event 
     308                        // generation 
     309                        if (menuList != null) { 
    308310                            if (menuElements.isEmpty()) { 
    309311                                // parse the menu structure 
     
    378380                } 
    379381                else if (event.getType() instanceof KeyPressed) { 
    380                     commitFocusEvent(); 
    381  
    382                     if (lastKeySequenceEvent == null) { 
    383                         lastKeySequenceEvent = structure.add("KeySequence"); 
    384                     } 
    385                     lastKeyTypedEvent = lastKeySequenceEvent.add("KeyTyped"); 
    386                     writeKeyEvent(writer, event, 401); 
     382                    handleKeyPressed(writer, event); 
    387383                } 
    388384                else if (event.getType() instanceof KeyReleased) { 
    389                     commitFocusEvent(); 
    390  
    391                     writeKeyEvent(writer, event, 402); 
     385                    handleKeyReleased(writer, event); 
    392386                } 
     387                else if (event.getType() instanceof TextInput) { 
     388                    handleTextInput(writer, event); 
     389                } 
     390            } 
     391        } 
     392    } 
     393 
     394    private void handleKeyPressed(BufferedWriter writer, Event event) throws IOException { 
     395        commitFocusEvent(); 
     396 
     397        if (lastKeySequenceEvent == null) { 
     398            lastKeySequenceEvent = structure.add("KeySequence"); 
     399        } 
     400        lastKeyTypedEvent = lastKeySequenceEvent.add("KeyTyped"); 
     401 
     402        writeKeyEvent(writer, event, 401); 
     403    } 
     404 
     405    private void handleKeyReleased(BufferedWriter writer, Event event) throws IOException { 
     406        commitFocusEvent(); 
     407 
     408        writeKeyEvent(writer, event, 402); 
     409    } 
     410 
     411    private void handleTextInput(BufferedWriter writer, Event event) throws IOException { 
     412        List<Event> textEvents = ((TextInput) event.getType()).getTextInputEvents(); 
     413 
     414        // just split the text event into its key events again 
     415        for (Event textEvent : textEvents) { 
     416            if (textEvent.getType() instanceof KeyPressed) { 
     417                handleKeyPressed(writer, textEvent); 
     418            } 
     419            else if (textEvent.getType() instanceof KeyReleased) { 
     420                handleKeyReleased(writer, textEvent); 
    393421            } 
    394422        } 
Note: See TracChangeset for help on using the changeset viewer.