use of net.runelite.client.input.MouseListener in project runelite by runelite.
the class GrandExchangePlugin method startUp.
@Override
protected void startUp() throws IOException {
panel = injector.getInstance(GrandExchangePanel.class);
BufferedImage icon;
synchronized (ImageIO.class) {
icon = ImageIO.read(getClass().getResourceAsStream("ge_icon.png"));
}
button = NavigationButton.builder().name("GE Offers").icon(icon).panel(panel).build();
pluginToolbar.addNavigation(button);
itemClick = new MouseListener() {
@Override
public MouseEvent mouseClicked(MouseEvent e) {
// Check if left click + alt
if (e.getButton() == MouseEvent.BUTTON1 && e.isAltDown()) {
Point mousePosition = client.getMouseCanvasPosition();
Widget inventoryWidget = client.getWidget(WidgetInfo.INVENTORY);
if (inventoryWidget != null && !inventoryWidget.isHidden()) {
for (WidgetItem item : inventoryWidget.getWidgetItems()) {
if (item.getCanvasBounds().contains(mousePosition.getX(), mousePosition.getY())) {
ItemComposition itemComp = client.getItemDefinition(item.getId());
if (itemComp != null) {
e.consume();
SwingUtilities.invokeLater(() -> {
panel.showSearch();
if (!button.isSelected()) {
button.getOnSelect().run();
}
panel.getSearchPanel().priceLookup(itemComp.getName());
});
}
break;
}
}
}
}
return super.mouseClicked(e);
}
};
if (config.quickLookup()) {
mouseManager.registerMouseListener(itemClick);
}
}
Aggregations