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.

� A dialog, containing a title bar, a help icon, a captioned control array, a button<br />

(Schedule), a page selector, and a button group.<br />

� A captioned control array with five captioned controls, including a numeric editor with<br />

up and down arrows.<br />

� A page selector with three tabs and left and right scroll arrows.<br />

� A button group with two buttons (Cancel and Done).<br />

That's 21 controls altogether, all lodging in a single window.<br />

For another example, see the Write file dialog in <strong>Chapter</strong> 11, which had two captioned<br />

controls and two buttons, for a total of 12 controls.<br />

It should be obvious that the dialog isn't the only container here. The captioned control array,<br />

and some controls themselves, are also important containers with their own responsibilities,<br />

as we'll see. What we think of as 'the controls' in the dialog (the five controls in the captioned<br />

control array we were talking about above) are more complicated than they appear, and<br />

account for only about a quarter of the controls actually on this dialog page.<br />

12.2.5 Key Distribution and Focus<br />

Here's a simplified account of how a dialog processes OfferKeyEventL() (for the full<br />

truth, check out CEikDialog::OfferKeyEventL() in the SDK).<br />

In UIQ, the primary method of text input is the FEP. UIQ provides two FEPs: a handwriting<br />

recognition method and an on-screen virtual keyboard; others may be written by third<br />

parties. Both FEPs receive pointer events and translate them into key events, which are<br />

passed to the application. Whether the key event is generated by a FEP or by a real<br />

keyboard shouldn't make any difference to your app. If you are creating a new control that<br />

can receive text input, you need to override CCoeControl's virtual<br />

InputCapabilities() method. This tells the FEP whether it can accept text input, and if<br />

so, which types of input are supported. The default implementation in CCoecontrol returns<br />

TCoeInputCapabilities::Enlone.<br />

At any one time, precisely one of the controls in the captioned control array has focus. That<br />

means the line is either highlighted, or displays a cursor, and is the recipient of 'most' key<br />

events. When the dialog is offered a key event, it handles some special cases itself (for<br />

instance, it offers Confirm to the dialog buttons), but otherwise it offers the key to the<br />

currently focused general-purpose control.<br />

Note<br />

A general-purpose control is one that can be used both in dialogs and app<br />

views. Incidentally to make a control intended for dialogs usable in app views<br />

isn't always difficult, and it's a good thing to aim for. But to make a control<br />

intended for app views usable in a dialog is rarely necessary, and you<br />

shouldn't try to do so without good reason.<br />

There are plenty of special cases (such as support for the page selector), but this description<br />

is enough to illustrate the role of focus, and also to begin to show why keys are offered, and<br />

why they are not always consumed.<br />

It's important to give a clear visual indication of focus and all the components work together<br />

to achieve this:<br />

� The dialog is the topmost window: it has focus merely by being there.<br />

� The buttons and the title bar can never receive focus so they don't need to change<br />

their drawing code in response to whether they're focused or not.

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

Saved successfully!

Ooh no, something went wrong!