Skip to content

Commit

Permalink
ADR: Tracker doesn't work with press other buttons at the same time
Browse files Browse the repository at this point in the history
ADR: Hotkeys of mouse
GRID: combobox margin
  • Loading branch information
Exslims committed Aug 6, 2017
1 parent 9da021b commit 024095e
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ public HotKeysConfigurationService(ProfileDescriptor selectedProfile) {
@Override
public Map<String, HotKeyDescriptor> getDefault() {
Map<String, HotKeyDescriptor> keyMap = new HashMap<>();
keyMap.put(HotKeyType.INVITE_PLAYER.name(),new HotKeyDescriptor(GlobalKeyEvent.VK_1,'1',true,false,false,false));
keyMap.put(HotKeyType.TRADE_PLAYER.name(),new HotKeyDescriptor(GlobalKeyEvent.VK_2,'2',true,false,false,false));
keyMap.put(HotKeyType.KICK_PLAYER.name(),new HotKeyDescriptor(GlobalKeyEvent.VK_3,'3',true,false,false,false));
keyMap.put(HotKeyType.STILL_INTERESTING.name(),new HotKeyDescriptor(GlobalKeyEvent.VK_4,'4',true,false,false,false));
keyMap.put(HotKeyType.CLOSE_NOTIFICATION.name(),new HotKeyDescriptor(GlobalKeyEvent.VK_5,'5',true,false,false,false));
keyMap.put(HotKeyType.EXPAND_ALL.name(),new HotKeyDescriptor(GlobalKeyEvent.VK_1,'1',false,false,true,false));
keyMap.put("button_1",new HotKeyDescriptor(GlobalKeyEvent.VK_1,'1',false,true,false,false));
keyMap.put("button_2",new HotKeyDescriptor(GlobalKeyEvent.VK_1,'2',false,true,false,false));
keyMap.put("button_3",new HotKeyDescriptor(GlobalKeyEvent.VK_1,'3',false,true,false,false));
keyMap.put("button_4",new HotKeyDescriptor(GlobalKeyEvent.VK_1,'4',false,true,false,false));
keyMap.put(HotKeyType.INVITE_PLAYER.name(),new HotKeyDescriptor("",GlobalKeyEvent.VK_1,'1',true,false,false,false));
keyMap.put(HotKeyType.TRADE_PLAYER.name(),new HotKeyDescriptor("",GlobalKeyEvent.VK_2,'2',true,false,false,false));
keyMap.put(HotKeyType.KICK_PLAYER.name(),new HotKeyDescriptor("",GlobalKeyEvent.VK_3,'3',true,false,false,false));
keyMap.put(HotKeyType.STILL_INTERESTING.name(),new HotKeyDescriptor("",GlobalKeyEvent.VK_4,'4',true,false,false,false));
keyMap.put(HotKeyType.CLOSE_NOTIFICATION.name(),new HotKeyDescriptor("",GlobalKeyEvent.VK_5,'5',true,false,false,false));
keyMap.put(HotKeyType.EXPAND_ALL.name(),new HotKeyDescriptor("",GlobalKeyEvent.VK_1,'1',false,false,true,false));
keyMap.put("button_1",new HotKeyDescriptor("",GlobalKeyEvent.VK_1,'1',false,true,false,false));
keyMap.put("button_2",new HotKeyDescriptor("",GlobalKeyEvent.VK_1,'2',false,true,false,false));
keyMap.put("button_3",new HotKeyDescriptor("",GlobalKeyEvent.VK_1,'3',false,true,false,false));
keyMap.put("button_4",new HotKeyDescriptor("",GlobalKeyEvent.VK_1,'4',false,true,false,false));
return keyMap;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
@AllArgsConstructor
@NoArgsConstructor
public class HotKeyDescriptor implements Serializable{
private String title = "";
private int virtualKeyCode;
private char keyChar;
private boolean menuPressed;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
package com.mercury.platform.shared.hotkey;

import com.mercury.platform.shared.config.descriptor.HotKeyDescriptor;
import com.mercury.platform.shared.store.MercuryStoreCore;
import lc.kra.system.keyboard.event.GlobalKeyAdapter;
import lc.kra.system.keyboard.event.GlobalKeyEvent;

public class HotKeyAdapter extends GlobalKeyAdapter {
private HotKeyDescriptor currentKey;
public void keyTyped(HotKeyDescriptor descriptor) {
}

@Override
public void keyPressed(GlobalKeyEvent event) {
this.currentKey = this.convert(event);
}

@Override
public void keyReleased(GlobalKeyEvent event) {
if(this.currentKey != null && this.currentKey.equals(this.convert(event))) {
this.keyTyped(this.currentKey);
}
MercuryStoreCore.hotKeySubject.onNext(this.convert(event));
}

private HotKeyDescriptor convert(GlobalKeyEvent event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,46 @@
import com.mercury.platform.shared.config.descriptor.HotKeyDescriptor;
import com.mercury.platform.shared.store.MercuryStoreCore;
import lc.kra.system.keyboard.GlobalKeyboardHook;
import lc.kra.system.mouse.GlobalMouseHook;
import lc.kra.system.mouse.event.GlobalMouseAdapter;
import lc.kra.system.mouse.event.GlobalMouseEvent;

public class HotKeysInterceptor {
public HotKeysInterceptor() {
GlobalKeyboardHook keyboardHook = new GlobalKeyboardHook(false);
keyboardHook.addKeyListener(new HotKeyAdapter() {
keyboardHook.addKeyListener(new HotKeyAdapter());

GlobalMouseHook mouseHook = new GlobalMouseHook(false);
mouseHook.addMouseListener(new GlobalMouseAdapter() {
@Override
public void keyTyped(HotKeyDescriptor descriptor) {
MercuryStoreCore.hotKeySubject.onNext(descriptor);
public void mousePressed(GlobalMouseEvent globalMouseEvent) {
MercuryStoreCore.hotKeySubject.onNext(this.convert(globalMouseEvent));
}
private HotKeyDescriptor convert(GlobalMouseEvent event) {
HotKeyDescriptor descriptor = new HotKeyDescriptor();
switch (event.getButton()){
case 1: {
descriptor.setVirtualKeyCode(1000);
descriptor.setTitle("Mouse left");
break;
}
case 2: {
descriptor.setVirtualKeyCode(1002);
descriptor.setTitle("Mouse right");
break;
}
case 16: {
descriptor.setVirtualKeyCode(1016);
descriptor.setTitle("Mouse middle");
break;
}
}
return descriptor;
}
});
}

public static void main(String[] args) {
new HotKeysInterceptor();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,32 +121,38 @@ public JPanel getLocationPanel(AdrComponentDescriptor descriptor, boolean fromGr
return root;
}

public JButton getHotKeyButton(AdrComponentDescriptor descriptor){
public JButton getHotKeyButton(AdrComponentDescriptor descriptor) {
JButton button = this.componentsFactory.getBorderedButton(this.getButtonText(descriptor.getHotKeyDescriptor()));
button.setFont(this.componentsFactory.getFont(FontStyle.BOLD,18f));
button.addMouseListener(new MouseAdapter() {
button.setFont(this.componentsFactory.getFont(FontStyle.BOLD, 18f));
MouseAdapter mouseAdapter = new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
button.setBackground(AppThemeColor.SLIDE_BG);
button.setText("Press any key");
allowed = true;
if(SwingUtilities.isLeftMouseButton(e)) {
button.setBackground(AppThemeColor.SLIDE_BG);
button.setText("Press any key");
allowed = true;
}
}
});
};
button.addMouseListener(mouseAdapter);
MercuryStoreCore.hotKeySubject.subscribe(hotKey -> {
if(allowed) {
if (allowed) {
button.removeMouseListener(mouseAdapter);
button.setBackground(AppThemeColor.BUTTON);
if(hotKey.getVirtualKeyCode() == 27){
if (hotKey.getVirtualKeyCode() == 27) {
descriptor.setHotKeyDescriptor(new HotKeyDescriptor());
}else {
} else {
descriptor.setHotKeyDescriptor(hotKey);
}
button.setText(getButtonText( descriptor.getHotKeyDescriptor()));
button.setText(getButtonText(descriptor.getHotKeyDescriptor()));
allowed = false;
MercuryStoreUI.adrReloadSubject.onNext(descriptor);
button.addMouseListener(mouseAdapter);
}
});
return button;
}

public JPanel getHotKeyPanel(AdrComponentDescriptor descriptor){
JButton hotKeyButton = this.getHotKeyButton(descriptor);
JPanel hotKeyPanel = this.componentsFactory.getJPanel(new BorderLayout());
Expand Down Expand Up @@ -820,6 +826,9 @@ private JColorChooser getColorChooser(){
return colorChooser;
}
private String getButtonText(HotKeyDescriptor descriptor){
if(!descriptor.getTitle().equals("")){
return descriptor.getTitle();
}
if(descriptor.getKeyChar() == '\u0000') {
return "...";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ protected JPanel getPanelForPINSettings() {
});
tabType.setPreferredSize(new Dimension((int)(componentsFactory.getScale() * 70),tabType.getHeight()));

labelPanel.add(tabType,BorderLayout.LINE_START);
labelPanel.add(this.componentsFactory.wrapToSlide(tabType,AppThemeColor.FRAME),BorderLayout.LINE_START);
Color titleColor = this.applicationConfig.get().isItemsGridEnable()?AppThemeColor.TEXT_NICKNAME:AppThemeColor.TEXT_DISABLE;
JLabel titleLabel = componentsFactory.getTextLabel(FontStyle.BOLD, titleColor, TextAlignment.LEFTOP, 20f, "Align this grid(approximately)");
labelPanel.add(titleLabel,BorderLayout.CENTER);
Expand Down

0 comments on commit 024095e

Please sign in to comment.