GEF-Learn the palette, things we don't know (3) shadow warrior Tracker

Source: Internet
Author: User

When studying the implementation of the GEF palette, I found a SWT control that I have never used before, probably because I rarelyProgramTo handle the mouse movement and other events. This good thing is tracker. I very much hope to call it a Shadow Warrior, because tracker often works with mouse clicks and movement events to dynamically display the changes in the position and size of the operated components, in a sense, tracker is very like GEF handle in SWT;

The following briefly introduces the basic usage of this tool. (In the GEF palette implementation, tracker is mainly used in the sash drag and the dock process of the palette)

Tracker directly inherits from Widgets. Like other widgets, constructor requires parent and style. parent is the control we need to track, so we will not go into details here. Tracker is called a Shadow Warrior mainly because tracker can display a rectangle in a shadow mode, which can be implemented through the setrectangles method, with this method name, we can see that a tracker can specify multiple rectangles. To tell the truth, I don't quite understand where to set multiple rectangles. At least I haven't touched them yet.

Of course, it is not the most important thing to set a rectangle. If you set a rectangle, the user will not feel very well. Therefore, there is another method: setstippled (Boolean) is used to specify whether to draw points in tracker, you can give it a try. It is generally nice to set to true;

In addition, the above settings are only the basic parameter settings, so how does trcker itself work? We need to mention another method of open, which only calls it, tracker will be displayed, and the movement of the mouse will be shown by our shadow warrior;

Of course, to better represent our moving direction, we 'd better set the tracker's cursor by: setcursor;

To sum up the usage of Tracker:

1. Define the mouse click and move event processor;

2. Define tracker as the tracker of a component;

3. Define the cursor and rectangle of the tracker;

4. Open tracker, that is, call method open;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.