The pages skill
pages is one action, show_page, which brings a tab of the form the user is working on to the front, as a click on it would. It does not ask first: it changes what is shown, not the data.
It exists because the other skills see what the user sees. A form with General, Addresses and Notes tabs shows the fields of one tab at a time, and describe_form lists only those: to fill the address, the model shows the Addresses page, describes again, and fills.
User: "put the delivery address: Via Roma 1, Milano"
→ describe_form() ... Pages: "General" (shown), "Addresses", "Notes" ...
→ show_page(page = "Addresses")
→ describe_form() ... edStreet, edCity ...
→ fill_form(values = {"edStreet": "Via Roma 1", "edCity": "Milano"}) [confirmed]Which pages
A page is a TTabSheet of a TPageControl on the form - in FireMonkey a TTabItem of a TTabControl - which the user could reach by clicking:
- its tab is visible (
TabVisible,Visiblefor aTTabItem) and enabled; - every control above it is visible - except the pages of outer page controls, which
show_pagebrings to the front first.
A TTabControl whose TabPosition is None has no tabs to click: it is a card panel the application drives by itself - the main window of the FireMonkey CRM demo is one - so its pages are not offered, and an action of the application (open_screen in the demo) is how the assistant moves between them.
A page inside a page is named by its path, the captions from the outermost in: Notes > Private. describe_form lists them all, marking the ones shown:
Pages: "General" (shown), "Addresses", "Notes", "Notes > Public", "Notes > Private".Finding the page
The model writes the caption it read; the skill looks for, in this order:
- a page whose caption is the same (case and hot-key mark apart), or whose path is, or whose control name is;
- the only page whose path contains the text - "private" finds Notes > Private; when two pages contain it, it lists them and lets the model choose.
A page that does not exist is answered with the pages that do, so the model never has to guess.
Showing it
From the outermost page in: to show Notes > Private, Notes first, then Private. For each page control it does what a click on the tab does:
- it asks the form - the
OnChangingof the page control may refuse, and then the page is not changed and the model is told the form refused to leave the current page; - it moves the caret out of the page being left, when it is there: the VCL keeps a page whose active control it cannot move, and a click takes the focus with it anyway;
- it activates the page, and checks that it is the active one now;
- it fires
OnChange, so the form does what it does when the user changes page - loading the details of a tab, say.
In FireMonkey, setting the ActiveTab of the tab control does all of it, OnChange included: there is no OnChanging to ask.
The answer tells the model what to do next: The page "Notes > Private" is shown: describe_form lists its fields.