MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / pointerPressed

Method pointerPressed

CodenameOne/src/com/codename1/ui/Form.java:3389–3522  ·  view source on GitHub ↗
(int x, int y)

Source from the content-addressed store, hash-verified

3387
3388 /// {@inheritDoc}
3389 @Override
3390 public void pointerPressed(int x, int y) {
3391 // Device-input dispatch happens here, at the form level, so it works uniformly for every
3392 // component (including ones such as Button that override pointerPressed without calling
3393 // super). A secondary (right / stylus barrel) button press is a context menu request; if a
3394 // listener consumes it the normal press is suppressed. Stylus presses are also surfaced
3395 // here so addStylusListener fires regardless of the target component.
3396 if (Display.getInstance().getPointerButton() == PointerEvent.BUTTON_SECONDARY) {
3397 Component ctxCmp = resolveInputComponent(x, y);
3398 if (ctxCmp != null && ctxCmp.fireContextMenu(x, y)) {
3399 return;
3400 }
3401 }
3402 if (Display.getInstance().isStylusPointer()) {
3403 Component stylusCmp = resolveInputComponent(x, y);
3404 if (stylusCmp != null) {
3405 stylusCmp.fireStylusEvent(ActionEvent.Type.PointerPressed, x, y);
3406 }
3407 }
3408 currentPointerPress = new Object();
3409 // a press (the start of a click or drag) dismisses any tooltip so it can't linger
3410 // over a drag image or get stranded when the gesture rebuilds the UI
3411 if (TooltipManager.getInstance() != null) {
3412 TooltipManager.getInstance().clearTooltip();
3413 }
3414 // See https://github.com/codenameone/CodenameOne/issues/2352
3415 if (resumeDragAfterScrolling(x, y)) {
3416 pointerPressedAgainDuringDrag = true;
3417 return;
3418 }
3419
3420
3421 setPressedCmp(null);
3422 stickyDrag = null;
3423 dragStopFlag = false;
3424 dragged = null;
3425 boolean isScrollWheeling = Display.impl.isScrollWheeling();
3426 if (pointerPressedListeners != null && pointerPressedListeners.hasListeners()) {
3427 ActionEvent e = new ActionEvent(this, ActionEvent.Type.PointerPressed, x, y);
3428 pointerPressedListeners.fireActionEvent(e);
3429 if (e.isConsumed()) {
3430 return;
3431 }
3432 }
3433 //check if the click is relevant to the menu bar.
3434 /*
3435 if (menuBar.contains(x, y)) {
3436 Component cmp = menuBar.getComponentAt(x, y);
3437 while (cmp != null && cmp.isIgnorePointerEvents()) {
3438 cmp = cmp.getParent();
3439 }
3440 if (cmp != null && cmp.isEnabled()) {
3441 cmp.pointerPressed(x, y);
3442 tactileTouchVibe(x, y, cmp);
3443 initRippleEffect(x, y, cmp);
3444 }
3445 return;
3446 }

Calls 15

getInstanceMethod · 0.95
resolveInputComponentMethod · 0.95
fireContextMenuMethod · 0.95
fireStylusEventMethod · 0.95
getInstanceMethod · 0.95
setPressedCmpMethod · 0.95
isConsumedMethod · 0.95
getActualPaneMethod · 0.95
getComponentAtMethod · 0.95
isIgnorePointerEventsMethod · 0.95
getParentMethod · 0.95