Java Code Examples for org.lwjgl.input.Mouse#getDWheel()

The following examples show how to use org.lwjgl.input.Mouse#getDWheel() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
private void handleScrolling(int mouseX, int mouseY) {
    final boolean inside = mouseX >= this.getX() && mouseX <= this.getX() + this.getW() && mouseY >= this.getY() && mouseY <= this.getY() + this.getH();
    if (inside && Mouse.hasWheel()) {
        this.scroll += -(Mouse.getDWheel() / 100);

        if (this.scroll <= 0) {
            this.scroll = 0;
        }

        if (this.scroll >= 10) {
            this.scroll = 10;
        }

        if (this.lastScroll != this.scroll) {
            this.lastScroll = this.scroll;
            this.distance = this.scroll * 10;
            //TODO update fbo
        }
    }
}
 
Example 2
private void handleScrolling(int mouseX, int mouseY) {
    final boolean inside = mouseX >= this.getX() && mouseX <= this.getX() + this.getW() && mouseY >= this.getY() && mouseY <= this.getY() + this.getH();
    if (inside && Mouse.hasWheel()) {
        this.scroll += -(Mouse.getDWheel() / 10);

        if (this.scroll < 0) {
            this.scroll = 0;
        }
        if (this.scroll > this.totalHeight - this.getH()) {
            this.scroll = this.totalHeight - (int) this.getH();
        }
    }
}
 
Example 3
private void handleScrolling(int mouseX, int mouseY) {
    final boolean inside = mouseX >= this.getX() && mouseX <= this.getX() + this.getW() && mouseY >= this.getY() && mouseY <= this.getY() + this.getH();
    if (inside && Mouse.hasWheel()) {
        this.scroll += -(Mouse.getDWheel() / 10);

        if (this.scroll < 0) {
            this.scroll = 0;
        }
        if (this.scroll > this.totalHeight - this.getH()) {
            this.scroll = this.totalHeight - (int) this.getH();
        }
    }
}
 
Example 4
public void updateScreen() {
    final int wheel = Mouse.getDWheel();
    final int increment = (int) Math.ceil(scrollbar.getMaxValue() / 10);
    if (wheel > 0) {
        scrollbar.setValue(scrollbar.getValue() - increment);
    }
    if (wheel < 0) {
        scrollbar.setValue(scrollbar.getValue() + increment);
    }
    super.updateScreen();
}
 
Example 5
Source Project: LowPolyWater   File: Camera.java    License: The Unlicense 5 votes vote down vote up
private void calculateZoom() {
	float targetZoom = distanceFromPlayer.getTarget();
	float zoomLevel = Mouse.getDWheel() * 0.0008f * targetZoom;
	targetZoom -= zoomLevel;
	if (targetZoom < 1) {
		targetZoom = 1;
	}
	distanceFromPlayer.setTarget(targetZoom);
	distanceFromPlayer.update(0.01f);
}
 
Example 6
Source Project: pycode-minecraft   File: GuiTextArea.java    License: MIT License 5 votes vote down vote up
/**
 * Increments the cursor counter and mouse scroll
 */
public void update() {
    // only interested in up to 12 ticks
    this.cursorCounter = (this.cursorCounter + 1) % 12;
    if (this.isFocused && Mouse.hasWheel()) {
        int newScroll = Mouse.getDWheel();
        if (newScroll != 0) {
            this.scrollBy(newScroll);
        }
    }
}
 
Example 7
@Override
public void handleMouseInput(){
    if(listening) {
        int wheel = -Mouse.getDWheel();
        wheel = MathHelper.clamp_int(wheel, -1, 1);
        currentScroll += (float)wheel / states;
    }
}
 
Example 8
Source Project: ExtraCells1   File: GuiTerminalFluid.java    License: MIT License 4 votes vote down vote up
@Override
public void initGui()
{
	super.initGui();
	fluidWidgets = new ArrayList<AbstractFluidWidget>();
	Mouse.getDWheel();

	List<Fluid> selectorFluids = new ArrayList<Fluid>();
	for (SpecialFluidStack stack : oldFluids)
	{
		fluidWidgets.add(new WidgetFluidSelector(this, stack));
		selectorFluids.add(stack.getFluidStack().getFluid());
	}
	for (Fluid fluid : oldCraftables)
		if (!selectorFluids.contains(fluid))
			fluidWidgets.add(new WidgetFluidRequest(this, fluid));

	for (AbstractFluidWidget widget : fluidWidgets)
	{
		if (widget instanceof WidgetFluidSelector && widget.getFluid() == oldSelected)
		{
			WidgetFluidSelector selector = (WidgetFluidSelector) widget;
			selector.setSelected(true);
			updateSelected(selector);
		}
	}
	Collections.sort(fluidWidgets, new FluidWidgetComparator());
	searchbar = new GuiTextField(fontRenderer, guiLeft + 81, guiTop - 12, 88, 10)
	{
		private int xPos = 0;
		private int yPos = 0;
		private int width = 0;
		private int height = 0;

		public void mouseClicked(int x, int y, int mouseBtn)
		{
			boolean flag = x >= xPos && x < xPos + width && y >= yPos && y < yPos + height;
			if (flag && mouseBtn == 3)
				setText("");
		}
	};
	searchbar.setEnableBackgroundDrawing(false);
	searchbar.setFocused(true);
	searchbar.setMaxStringLength(15);
}