Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public class CoachMarks
- Object
- CoachMarks
Coach marks (also called a feature tour, product walkthrough, onboarding overlay, spotlight or showcase view): the screen is dimmed, one component at a time is lit through a cut-out, and a bubble next to it says what it does.
Form form = new Form("Orders", BoxLayout.y());
Button search = new Button("Search");
Button filter = new Button("Filter");
Button add = new Button("New order");
form.add(FlowLayout.encloseIn(search, filter, add));
form.show();
new CoachMarks(form)
.add(search, "Search", "Find any order by number or name.")
.add(filter, "Filters", "Narrow the list to what is still open.")
.add(add, "New order", "Start an order from here.")
.showOnce("orders-tour");A tap on the dim or on “Next” moves to the next step, “Skip” ends the tour,
and the last step’s button reads “Done”. #showOnce(String) shows the tour
the first time only and remembers that in Preferences, which is what an
onboarding tour usually wants; #show() shows it every time. A tour of one
step is a single feature highlight.
While the tour is up, touches go to it and not to the form under it. Each step is announced to screen readers.
UIIDs: CoachMarkOverlay (its background colour and transparency are the
dim), CoachMarkBubble, CoachMarkTitle, CoachMarkText, CoachMarkStep
and CoachMarkButton. A theme that does not style them gets a light or dark
bubble to match the platform’s appearance. The button labels are localized
through the keys CoachMarkNext, CoachMarkDone and CoachMarkSkip.
This replaces the deprecated GlassTutorial.
Constructors
public CoachMarks(Form form) | A tour over a form. |
Methods
public CoachMarks add(Component target, String title, String text) | Adds a step that lights a component. |
public CoachMarks setOnFinish(Runnable onFinish) | Runs code when the tour ends, whether it was finished or skipped. |
public CoachMarks setSkippable(boolean skippable) | Whether the bubble offers “Skip”. |
public int getStepCount() | The number of steps. |
public int getCurrentStep() | The step on screen. |
public boolean isShowing() | Whether the tour is on screen. |
public boolean showOnce(String key) | Shows the tour the first time this is called with a key, and does nothing on later calls, across restarts of the app. |
public static void resetShowOnce(String key) | Forgets that a tour was shown by #showOnce(String), so it shows again, for a “show the tips again” setting. |
public void show() | Shows the tour from its first step. |
public void next() | Moves to the next step, or ends the tour after the last one. |
public void dismiss() | Ends the tour and runs the code given to #setOnFinish(Runnable). |
Inherited methods
Constructor details
CoachMarks
public CoachMarks(Form form)#add(Component, String, String).Parameters
formForm- the form whose components the steps point at
Method details
add
public CoachMarks add(Component target, String title, String text)Parameters
targetComponent- the component to light; it must be on the form when its step shows
titleString- a short title, or null
textString- what the component does
Returns
setOnFinish
public CoachMarks setOnFinish(Runnable onFinish)Parameters
onFinishRunnable- the code to run, or null
Returns
setSkippable
public CoachMarks setSkippable(boolean skippable)Parameters
skippableboolean- false to hide the skip button
Returns
getStepCount
public int getStepCount()Returns
getCurrentStep
public int getCurrentStep()Returns
isShowing
public boolean isShowing()Returns
showOnce
public boolean showOnce(String key)Parameters
keyString- a name for this tour, unique within the app
Returns
resetShowOnce
public static void resetShowOnce(String key)#showOnce(String), so it shows again,
for a “show the tips again” setting.Parameters
keyString- the key the tour was shown with
show
public void show()next
public void next()dismiss
public void dismiss()#setOnFinish(Runnable).