Skip to content

you broke button "released" #3047

@ddyer0

Description

@ddyer0

This (recent?) change to com.codename1.ui.Button requires that the x,y be near
the press point, but the value being supplied from the form is 1,1 relative to the
origin of the button, hence, button release events are never triggered.

''''java
/**
* Invoked to change the state of the button to the released state
*
* @param x the x position if a touch event triggered this, -1 if this isn't relevant
* @param y the y position if a touch event triggered this, -1 if this isn't relevant
*/
public void released(int x, int y) {
if (!Display.impl.isScrollWheeling()) {
if (state != STATE_ROLLOVER) {
state=STATE_ROLLOVER;
fireStateChange();
}
if (Math.abs(x - pressedX) < CN.convertToPixels(1) && Math.abs(y-pressedY) < CN.convertToPixels(1)) {
fireActionEvent(x, y);
}

        repaint();
    }

''''

in Form.java
''''java
if(pendingC instanceof ReleasableComponent) {
ReleasableComponent rc = (ReleasableComponent) pendingC;
int relRadius = rc.getReleaseRadius();
if(relRadius > 0 || pendingC.contains(x, y)) {
Rectangle r = new Rectangle(pendingC.getAbsoluteX() - relRadius, pendingC.getAbsoluteY() - relRadius, pendingC.getWidth() + relRadius * 2, pendingC.getHeight() + relRadius * 2);
if(r.contains(x, y)) {
componentsAwaitingRelease = null;
pointerReleased(pendingC.getAbsoluteX() + 1, pendingC.getAbsoluteY() + 1);
return;
}
}
''''

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions