Java 类net.minecraftforge.client.event.GuiScreenEvent.MouseInputEvent 实例源码

项目:VisibleArmorSlots    文件:EventDelegatorGuiOverlay.java   
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onMouseInputEvent(MouseInputEvent.Pre event)
{
    // Only accepts clicks - 0 = left, 1 = right, 2 = middle
    if (Mouse.getEventButton() < 0) { return; }
    if (!this.shouldDisplayGuiOverlay(event.getGui())) { return; }


    final boolean shouldCancelEvent = this.getGuiOverlay().handleMouseInput();

    if (shouldCancelEvent) {
        // Prevents clicks on the gui overlay dropping items on the world
        event.setCanceled(true);
    }

}
项目:Aether-Legacy    文件:AetherClientEvents.java   
@SubscribeEvent
public void onMouseClicked(MouseInputEvent.Post event)
{
    if (event.getGui() instanceof GuiContainerCreative)
    {
        GuiContainerCreative guiScreen = (GuiContainerCreative) event.getGui();
        List<GuiButton> buttonList = ObfuscationReflectionHelper.getPrivateValue(GuiScreen.class, (GuiScreen) guiScreen, 7);

        if (previousSelectedTabIndex != guiScreen.getSelectedTabIndex())
        {
            if (guiScreen.getSelectedTabIndex() == CreativeTabs.INVENTORY.getTabIndex() && !buttonList.contains(ACCESSORY_BUTTON))
            {
                int guiLeft = ObfuscationReflectionHelper.getPrivateValue(GuiContainer.class, (GuiContainer)event.getGui(), "guiLeft", "field_147003_i");
                int guiTop = ObfuscationReflectionHelper.getPrivateValue(GuiContainer.class, (GuiContainer)event.getGui(), "guiTop", "field_147009_r");

                buttonList.add(ACCESSORY_BUTTON.setPosition(guiLeft + 73, guiTop + 38));
            }
            else if (previousSelectedTabIndex == CreativeTabs.INVENTORY.getTabIndex())
            {
                buttonList.remove(ACCESSORY_BUTTON);
            }

            previousSelectedTabIndex = guiScreen.getSelectedTabIndex();
        }
    }
}
项目:NotEnoughItems    文件:ContainerEventHandler.java   
@SubscribeEvent (priority = EventPriority.LOWEST, receiveCanceled = true)//We need to be called before JEI.
public void onGuiMouseEventpre(MouseInputEvent.Pre event) {
    if (Mouse.getEventButton() == -1 || event.getGui() == null || !Mouse.getEventButtonState()) {
        return;
    }
    Point mouse = GuiDraw.getMousePosition();
    int eventButton = Mouse.getEventButton();
    if (JEIIntegrationManager.searchBoxOwner == EnumItemBrowser.JEI) {
        GuiTextFieldFilter fieldFilter = JEIIntegrationManager.getTextFieldFilter();
        if (fieldFilter != null && fieldFilter.isMouseOver(mouse.x, mouse.y)) {
            if (eventButton == 0) {
                if (fieldFilter.isFocused() && (System.currentTimeMillis() - lastSearchBoxClickTime < 500)) {//double click
                    NEIClientConfig.world.nbt.setBoolean("searchinventories", !SearchField.searchInventories());
                    NEIClientConfig.world.saveNBT();
                    lastSearchBoxClickTime = 0L;
                } else {
                    lastSearchBoxClickTime = System.currentTimeMillis();
                }
            } else if (eventButton == 1) {
                NEIClientConfig.setSearchExpression("", false);
                LayoutManager.searchField.setText("", false);
            }
        }
    }
}
项目:enderutilities    文件:GuiEnderUtilities.java   
@SubscribeEvent(priority = EventPriority.LOW)
public static void onMouseInputEventPre(MouseInputEvent.Pre event)
{
    // Handle the mouse input inside all of the mod's GUIs via the event and then cancel the event,
    // so that some mods like Inventory Sorter don't try to sort the Ender Utilities inventories.
    // Using priority LOW should still allow even older versions of Item Scroller to work,
    // since it uses normal priority.
    if (event.getGui() instanceof GuiEnderUtilities)
    {
        try
        {
            event.getGui().handleMouseInput();
            event.setCanceled(true);
        }
        catch (IOException e)
        {
            EnderUtilities.logger.warn("Exception while executing handleMouseInput() on {}", event.getGui().getClass().getName());
        }
    }
}