Utilizing Touch Inputs to Resize Panels in GWT

Recently, I encountered a challenge with the size of my Panel while loading numerous widgets inside it. To address this issue, I opted to utilize a Resizable Panel in GWT, which initially proved to be effective.

However, my current dilemma lies in adapting this functionality for Touch Enabled Devices such as Android Tablets and iPads. Since the Resize Panel relies on Mouse Drag Events, I am uncertain about how to integrate Touch Events instead.

I came across the GWT-DND API, which offers Resizable Panels that are compatible with touch interfaces. While this seems like a viable solution, I'm hesitant to take on the additional complexity it may entail.

If anyone has experience or insight into this matter, I would greatly appreciate any help or guidance you can provide.

Answer №1

I finally found the solution. It turned out to be quite simple - I just added touch handlers similar to mouse events that I had previously used.

  • ONTOUCHSTART = ONMOUSEDOWN
  • ONTOUCHMOVE = ONMOUSEMOVE
  • ONTOUCHEND = ONMOUSEUP
  • ONTOUCHCANCEL = ONLOSECAPTURE

ResizePanel.java

/**
 * Abstract base class for {@link VerticalResizePanel}.
 */
abstract class ResizePanel extends Panel implements HasResizeHandlers {

    /* **************************************** */
    // Private Static Fields
    /* **************************************** */
    /**
     * The element that masks the screen so we can catch mouse events over
     * iframes.
     */
    private static Element glassElem = null;

    /** The handler manager for our events. */

    /* **************************************** */
    // Private Fields
    /* **************************************** */
    // The elements containing the widgets.
    /** The elements. */
    private final Element[] elements = new Element[1];

    /** The handler manager for our events. */

    private final EventBus resizeHandlerManager = new SimpleEventBus();

    // Indicates whether drag resizing is active.
    /** The is resizing. */
    private boolean isResizing = false;

    // The element that acts as the splitter.
    /** The split elem. */
    private final Element splitElem;

    // The enclosed widgets.
    /** The widgets. */
    private final Widget[] widgets = new Widget[2];
    
    // More code...

}

In addition, here are my custom Event and Event Handlers:

ResizeEvent.java

/**
 * This event adjusts positions when panels (e.g. VerticalSplitPanel) are resized.
 */
public class ResizeEvent extends GwtEvent<ResizeEventHandler> {

    /* **************************************** */
    // Public Static Fields
    /* **************************************** */
    /** The Constant TYPE. */
    public static final Type<ResizeEventHandler> TYPE = new Type<ResizeEventHandler>();

    /* **************************************** */
    // Private Fields
    /* **************************************** */
    /** The split size. */
    private final int splitSize;

    // More code...

}

ResizeEventHandler.java

/**
 * Interface for handling resize events.
 */
public interface ResizeEventHandler extends EventHandler {

    /**
     * Handles the resize event.
     * 
     * @param event
     *            The resize event.
     */
    void onResize(ResizeEvent event);
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

iOS Safari enlarges frameset beyond viewport limits

I am currently designing a website that utilizes a frameset featuring a horizontal split - a menu sidebar on the left and a content area. <!DOCTYPE html> <html> <head> <title>Frameset Test</title> </head> ...

Can an animation be created that transforms an SVG line into a flawless circle?

Is there a way to create an animation that starts with an SVG line and gradually widens from the center to form a perfect circle? I've been researching this, but haven't found a solution that meets my needs. It could be because of the keywords I ...

Switching JSON data when clicked in Angular 2

Looking for a way to dynamically switch between different data sets in JSON upon user interaction with UI buttons. I am utilizing Angular 2 framework for this task. The HTML structure is as follows: <button type="button" (click)="changeOdds('odds ...

Using Java and Cucumber, extract @CucumberOptions from an external source such as a property file

Can cucumber option values be extracted from a java .properties file? A post on Stack Overflow indicates that the values are currently being passed through the command line interface (CLI). Below is an example of my code: @RunWith(Cucumber.class) @Cucum ...

The layout in Next.js production builds appears to be distinct from the layout in the

Currently, I am working on a website where I have implemented a dark theme by adding a class to the body element. Everything is functioning perfectly in the development environment, but I am encountering issues in the production build. Here is the root l ...

Updating an Excel file with Apache POI for both reading and writing operations

I am looking to read data from an excel file and write to the same excel based on certain conditions. For instance Empno Name Salary 1 Jonh 2000 2 Sam 3000 3 Dean 7000 Now my requirement is 1) I want to retrieve t ...

default radio option with pre-selected value

Below is a radio option list, but I'm having trouble getting the desired default selection on first render: <label class="radio normalFontWeight"> <input type="radio" name="Criteria" data-ng-value="EVERYONE_REVIEWED" data-ng- ...

Is it possible to maintain line breaks when using ".text" or ".textContent"? Any other options or solutions available? Workarounds to consider?

When trying to copy HTML from one element and paste it as text in another element, I noticed that newlines are not retained in the latest versions of Firefox and Chromium. For instance, if you run the code below (with valid HTML), the output will have the ...

What is the best method for checking for JavaScript errors when using Selenium WebDriver in conjunction with NodeJS?

When it comes to coding in JavaScript, not Java, my focus is on running a specific website like foo.com. I typically set it up as follows: var webdriver = require("selenium-webdriver"); By = webdriver.By, until = webdriver.until; var chrome = req ...

Constrained and Proportional Resizing with KineticJS

Dragging any of the 4 corner handles of the image should result in proportional scaling, either up or down. Issue: I am facing a problem with my current approach as illustrated in the provided link to jsfiddle. When the topLeft handles are moved verticall ...

What is the best way to access a model attribute in every template?

My goal is to showcase the name of my model team in the website header. The Team model has a attribute named "name": class Team(models.Model): name = models.CharField(max_length=50, null=True, blank=True) In my template language, I am trying to disp ...

Using the Petite-vue Initialization attribute within an HTML script tag

I came across a snippet of Vue.js code on Twitter from Evan You, but I'm confused about the purpose of the init attribute in the script tag. I've searched on MDN and other sites but couldn't find any information about it. However, I do unde ...

jQuery-powered unique serial numbers for tables

I've encountered an issue with my dynamic table that consists of 2 dynamic rows including students, their subjects, and marks. The code in question is provided below: Feel free to check out the code here Snippet for Serial Number function gene ...

What to do when trying to click an element without a tag present

<a href="" class="ng-binding ng-scope outside-month">1</a> <a href="" class="ng-binding ng-scope">1</a> My goal is to click on the second element without the outside-month tag. How can I make this happen? Should I use a specific s ...

Tips for finding an unstable table element with Selenium?

Below is the HTML code snippet: <table class="wikitable openei-infobox"> <tbody><tr> <th> <a href="/wiki/Property:Name" title="Property:Name">Name</a> </th> <td> Ambit Energy, L.P. <p ...

Eliminate the margin for the toolbar title in ActionMode

I'm trying to eliminate the gap between the navigation icon and the title of my actionMode. I successfully removed it for the toolbar using the following code: <style name="AppTheme" parent="Theme.MaterialComponents.Light"> <item nam ...

Animate an image to the right when clicked, then return it to the left with a second click

Seeking help with animating a set of images to move individually 300px right on first click, and then 300px left when clicked again. I'm currently facing an issue where my code is not working. It could be due to A) syntax errors or B) the images not ...

Does the WeakReference object get garbage collected together with the referenced object?

Here is a code snippet to consider: private void foo() { A a = new A(); WeakReference<A> weakA = new WeakReference<A>(a); a = null; while (true) { if (weakA.get() != null) System.out.println("weakA.get() != ...

Showing an array in tabular form using Angular

I have a single-element list that appears as shown below view image of array and contents My goal is to present the data in a table with headers for Author Name and Title. However, my current code displays all the titles in one row instead of creating se ...

Tips for utilizing the jQuery selectbox plugin on multiple elements within a single page

On my webpage, there are 3 select boxes that I want to customize using a jQuery selectbox plugin. However, the issue I'm encountering is that the plugin only works on the first select box and the others remain unchanged. Does anyone know why this mig ...