0

Currently I'm working on an basic application that has a 'tutorial mode'. Initially hints (bubbles with text) will be displayed above various ui elements, explaining how they work. Currently I have a main view which contains a hint object that can be updated (position, text, etc.) and I'm dispatching update events from the various views that need to display a hint. In most cases when the user click a hint, it disappears, but there are a few situations when the user must perform another action(like dragging-dropping an element, clicking another,etc.) to progress.

Phew, that's the background in a nutshell. My main question is:

Should there be dispatching events from various views and handle the hints centrally or should hints only be handled locally within each view ? What's the recommended approach ?

1 Answer 1

1

I'd suggest having hints dealt with in their own class, including body of the hint (so you can change it). To call it, just add one line of code, like:

 if ( hintsOn ) { HintHandeler.display ( ); }

The less the call to the hints needs to know, the better. Try to have whatever must be dealt with to be dealt with in the Hints class

To find out where the HintHandeler call came from, make use of: Thread.currentThread().getStackTrace(), and lex it as needed to find out where you came from. Ideally, store that in a variable, then have a massive switch{} statement, if possible (for speed), go down the list of places a call might be made from, and call additional code as necessary.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.