Ctrl+Left click opens context menus

cusax-fix
Yana Stamcheva 20 years ago
parent 14390c2edb
commit 4e8a62c8c6

@ -155,7 +155,8 @@ public void mouseExited(MouseEvent e) {
public void mousePressed(MouseEvent e) {
// Select the contact under the right button click.
if ((e.getModifiers() & InputEvent.BUTTON2_MASK) != 0
|| (e.getModifiers() & InputEvent.BUTTON3_MASK) != 0) {
|| (e.getModifiers() & InputEvent.BUTTON3_MASK) != 0
|| (e.isControlDown() && !e.isMetaDown())) {
this.contactList.setSelectedIndex(contactList.locationToIndex(e
.getPoint()));
}
@ -175,12 +176,12 @@ public void mousePressed(MouseEvent e) {
int translatedX = e.getX() - selectedCellPoint.x;
int translatedY = e.getY() - selectedCellPoint.y;
if(selectedValue instanceof MetaContactGroup) {
MetaContactGroup group = (MetaContactGroup) selectedValue;
if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0) {
if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0
|| (e.isControlDown() && !e.isMetaDown())) {
GroupRightButtonMenu popupMenu
= new GroupRightButtonMenu(mainFrame, group);
@ -207,12 +208,10 @@ public void mousePressed(MouseEvent e) {
Component component = renderer.getComponentAt(translatedX,
translatedY);
if (component instanceof JLabel) {
//Left click on the contact label opens Chat window
if ((e.getModifiers() & InputEvent.BUTTON1_MASK) != 0) {
SwingUtilities.invokeLater(new RunMessageWindow(contact));
}
//Right click on the contact label opens Popup menu
else if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0) {
//Right click and Ctrl+LeftClick on the contact label opens
//Popup menu
if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0
|| (e.isControlDown() && !e.isMetaDown())) {
ContactRightButtonMenu popupMenu
= new ContactRightButtonMenu(mainFrame, contact);
@ -227,6 +226,10 @@ else if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0) {
popupMenu.setVisible(true);
}
//Left click on the contact label opens Chat window
else if ((e.getModifiers() & InputEvent.BUTTON1_MASK) != 0) {
SwingUtilities.invokeLater(new RunMessageWindow(contact));
}
}
else if (component instanceof JButton) {
//Click on the info button opens the info popup panel
@ -251,7 +254,6 @@ else if (component instanceof JPanel) {
}
}
}
}
}

@ -15,6 +15,7 @@
import java.awt.*;
import java.awt.datatransfer.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.text.*;
@ -600,37 +601,46 @@ public void setCarretToEnd()
*/
public void mouseClicked(MouseEvent e)
{
if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0) {
if (currentHref != null) {
if (currentHref != "") {
rightButtonMenu.insert(openLinkItem, 0);
rightButtonMenu.insert(copyLinkItem, 1);
rightButtonMenu.insert(copyLinkSeparator, 2);
}
else {
rightButtonMenu.remove(openLinkItem);
rightButtonMenu.remove(copyLinkItem);
rightButtonMenu.remove(copyLinkSeparator);
}
}
Point p = e.getPoint();
SwingUtilities.convertPointToScreen(p, e.getComponent());
if(chatEditorPane.getSelectedText() != null) {
rightButtonMenu.enableCopy();
if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0
|| (e.isControlDown() && !e.isMetaDown())) {
openContextMenu(p);
}
}
/**
* Opens this panel context menu at the given point.
* @param p the point where to position the left-top cornet of the
* context menu
*/
private void openContextMenu(Point p)
{
if (currentHref != null) {
if (currentHref != "") {
rightButtonMenu.insert(openLinkItem, 0);
rightButtonMenu.insert(copyLinkItem, 1);
rightButtonMenu.insert(copyLinkSeparator, 2);
}
else {
rightButtonMenu.disableCopy();
rightButtonMenu.remove(openLinkItem);
rightButtonMenu.remove(copyLinkItem);
rightButtonMenu.remove(copyLinkSeparator);
}
}
Point p = e.getPoint();
SwingUtilities.convertPointToScreen(p, e.getComponent());
rightButtonMenu.setInvoker(chatEditorPane);
rightButtonMenu.setLocation(p.x, p.y);
rightButtonMenu.setVisible(true);
if(chatEditorPane.getSelectedText() != null) {
rightButtonMenu.enableCopy();
}
else {
rightButtonMenu.disableCopy();
}
rightButtonMenu.setInvoker(chatEditorPane);
rightButtonMenu.setLocation(p.x, p.y);
rightButtonMenu.setVisible(true);
}
public void mousePressed(MouseEvent e)
{
}

@ -215,7 +215,8 @@ public void stopTypingTimer() {
* right mouse button on the editor area.
*/
public void mouseClicked(MouseEvent e) {
if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0) {
if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0
|| (e.isControlDown() && !e.isMetaDown())) {
Point p = e.getPoint();
SwingUtilities.convertPointToScreen(p, e.getComponent());

Loading…
Cancel
Save