sketchub icon

Disable Long Press Events "Java-Code"

Get...
1 Likes
1 Comments
10 Downloads

Screenshots

About

UI Control: Disable Long Press Events

Enhance your App's UX by preventing unwanted interactions. This algorithm creates a "Void Method" that consumes the Long-Click event on any target View, ensuring only standard clicks are registered.

⚙️ How it works:

  • Olan made sure to unzip the loaded file.
  • Target: Sketchware Pro / Android Studio.
  • Logic: It overrides the OnLongClickListener and returns true to consume the event, effectively blocking the system's default response.
  • Usage: Create a Void Block (More Block) with one View parameter, and paste the code inside.

Source Code 👇

public void blockLongPress(View _view) {
    // 9. Prevent Long Press (Event Consumer)
    _view.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            // Return true to consume the event & block default behavior
            return true; 
        }
    });
}

©2026 Sketchub | User Policy