03.01.2013 Views

Chapter 1

Chapter 1

Chapter 1

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

12.4 Pointer Processing Revisited<br />

The window server ensures that a pointer event gets to the right window, and the control<br />

environment framework ensures that it gets to the right control. The event can then be<br />

handled by HandlePointerEventL().<br />

12.4.1 Interaction Paradigms<br />

A control should interpret the entire pointer sequence. Two sequences in particular are very<br />

common.<br />

Press-and-release is appropriate for many types of buttons:<br />

� Pen down inside the button: provide visual feedback by making it obvious that the<br />

button is pressed down.<br />

� Pen may stay down and/or be dragged for an arbitrary period.<br />

� Pen up: if the pen is outside the button, release it, redraw it in its neutral state, and do<br />

nothing. If the pen is inside the button, release it, redraw it, and then do the action<br />

associated with the button.<br />

Other related sequences are possible. For instance, UIQ supports buttons that activate as<br />

soon as you press them, whose state toggles, or which expand to show a drop-down list<br />

when pressed, so that you can drag and release on one of the items. There are many<br />

alternatives.<br />

In UIQ, a single tap to select and 'open' is used, where other systems would use double-click<br />

or two taps. Pen down on an item selects and opens it – in the case of COppFleetView,<br />

'open' means 'request a hit on'; in the case of the Application launcher, 'open' means open<br />

the application (or, if its already open, switch to it).<br />

12.4.2 Pick Correlation<br />

Pick correlation means associating the right object with a pointer event. As we saw in<br />

HandlePointerEventL() for COppFleetView at the start of the chapter, this was very<br />

easy to do:<br />

� There is only one object type that could have been selected: a sea tile,<br />

� The object is rectangular,<br />

� The object is part of a simple grid.<br />

This meant that selecting the object was a matter of a simple bounds checking and division.<br />

In more complicated cases (such as selecting text in a word processor, or an object in a<br />

vector graphics package), pick correlation can be an awkward business, and can involve<br />

even more optimization and complexity than is involved in drawing. However, you can use a<br />

few handy techniques to make life easier:<br />

� Object orientation makes designing for pick correlation easier, just as it does most<br />

things.<br />

� Construct a pick list optimized for easy checking when a pointer event occurs.<br />

It so happens that you can often use the same code to handle both incremental redraw and<br />

pick correlation requirements. (You can see this happening quite clearly in<br />

COppFleetView: the precalculated border and tile positions and sizes are used by both<br />

drawing and pick correlation.) The net effect is that your redraw and pick correlation code<br />

can be optimized together. Often, optimizing feels like inventing two solutions to solve one<br />

problem. In this case, one solution solves two problems, which is nice.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!