Changeset 29588 in osm for applications


Ignore:
Timestamp:
2013-05-13T20:40:53+02:00 (11 years ago)
Author:
akks
Message:

[josm_geochat] copypaste from keyboard, font size advanced parameters

Location:
applications/editors/josm/plugins/geochat
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/geochat/build.xml

    r29571 r29588  
    1515
    1616    <!-- enter the SVN commit message -->
    17     <property name="commit.message" value="GeoChat"/>
     17    <property name="commit.message" value="[josm_geochat] copypaste from keyboard, font size advanced parameters"/>
    1818    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    1919    <property name="plugin.main.version" value="4666"/>
  • applications/editors/josm/plugins/geochat/src/geochat/ChatPaneManager.java

    r29584 r29588  
    1010import javax.swing.event.ChangeListener;
    1111import javax.swing.text.*;
     12import org.openstreetmap.josm.Main;
    1213import static org.openstreetmap.josm.tools.I18n.tr;
    1314
     
    134135        chatPane.setEditable(false);
    135136        Font font = chatPane.getFont();
    136         float size = -1.0f; // Main.pref.getInteger("geochat.fontsize", -1); <- we don't need this
    137         if( size < 8 )
    138             size += font.getSize2D();
    139         chatPane.setFont(font.deriveFont(size));
     137        float sizeParameter = Main.pref.getInteger("geochat.panel.fontsize", -1);
     138        float size = sizeParameter;
     139        if ( sizeParameter <= 0 ) size += font.getSize2D();
     140        chatPane.setFont(font.deriveFont( size ));
     141
    140142//        DefaultCaret caret = (DefaultCaret)chatPane.getCaret(); // does not work
    141143//        caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
  • applications/editors/josm/plugins/geochat/src/geochat/GeoChatPanel.java

    r29584 r29588  
    5656            }
    5757        };
    58 
     58       
     59        Font font = input.getFont();
     60        float sizeParameter = Main.pref.getInteger("geochat.input.fontsize", 0);
     61        float size = sizeParameter;
     62        if ( sizeParameter <= 0 ) size += font.getSize2D();
     63        input.setFont(font.deriveFont( size ));
     64       
    5965        String defaultUserName = constructUserName();
    6066        loginPanel = createLoginPanel(defaultUserName);
  • applications/editors/josm/plugins/geochat/src/geochat/JPanelTextField.java

    r29584 r29588  
    33
    44import java.awt.KeyboardFocusManager;
     5import java.awt.event.InputEvent;
    56import java.awt.event.KeyEvent;
    6 import java.util.*;
     7import java.util.HashSet;
    78import javax.swing.*;
    89import javax.swing.text.DefaultEditorKit;
     
    1819 */
    1920public class JPanelTextField extends JTextField {
    20 
     21   
    2122    public JPanelTextField() {
    2223        setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, new HashSet<KeyStroke>());
    2324        PopupMenuLauncher launcher = new PopupMenuLauncher(createEditMenu());
    2425        addMouseListener(launcher);
     26        standardKeys = getInputMap(JComponent.WHEN_FOCUSED).allKeys();
    2527    }
    2628
     
    3941        return item;
    4042    }
     43
     44    // list of "standard" OS keys for JTextFiels = cursor moving, selection, copy/paste
     45    private final KeyStroke[] standardKeys;
     46    private static final int MODIFIERS_MASK = InputEvent.META_DOWN_MASK | InputEvent.CTRL_DOWN_MASK | InputEvent.ALT_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK;
    4147
    4248    @Override
     
    7480                if( Main.map != null && Main.map.mapView != null )
    7581                    Main.map.mapView.requestFocus();
     82            }
     83
     84            boolean keyIsStandard = false;
     85            for (KeyStroke ks: standardKeys) {
     86                if (code == ks.getKeyCode() &&
     87                       (e.getModifiersEx() & MODIFIERS_MASK) == (ks.getModifiers() & MODIFIERS_MASK)) {
     88                    keyIsStandard = true;
     89                    break;
     90                }
    7691            }
    7792            // Do not pass other events to JOSM
    78             if( code != KeyEvent.VK_LEFT && code != KeyEvent.VK_HOME && code != KeyEvent.VK_RIGHT && code != KeyEvent.VK_END && code != KeyEvent.VK_BACK_SPACE && code != KeyEvent.VK_DELETE )
     93            if( !keyIsStandard ) {
    7994                e.consume();
     95            }
    8096        }
    8197        super.processKeyEvent(e);
Note: See TracChangeset for help on using the changeset viewer.