ubuntu-phone team mailing list archive
-
ubuntu-phone team
-
Mailing list archive
-
Message #10412
Re: [Scopes] Responding to preview actions
On 7 Nov 2014, at 5:52 , Robert Schroll <rschroll@xxxxxxxxx> wrote:
> Hi all,
>
> I'm trying to understand how to have a scope respond to the user's activation of a preview action, by running a new query for example. This only documentation I've seem on it is in the API docs, and that's not entirely clear. I don't understand the difference between ScopeBase::perform_action and ScopeBase::activate, for instance.
ScopeBase::perform_action is what is called by the run time if you have registered one or more buttons, that is, if your preview includes a PreviewWidget of type "actions". You return an instance derived from ActivationQueryBase from perform_action. The ActivationQueryBase has an activate() method that you implement. The job of activate() is to tell the dash what to do in response to the button press. If you want to run a new query, you return an ActivationResponse from activate() with a status of PerformQuery, by constructing the ActivationResponse from a CannedQuery. The shell runs that query in response to the button press.
Normally, when a result is activated, the shell will use the URI of the result to trigger the correct action. This work if the URI schema has a handler in the system. If you want to override this default behavior, or if the result contains a schema that doesn't have a handler, you can override ScopeBase::activate(). If you do and, in addition, have called set_intercept_activation() on the result when you pushed it, the run time calls ScopeBase activate() instead of triggering the default action. From there, things are much like for previews, that is, your activate() method returns an ActivationQueryBase that then has its activate() method called to tell the shell what to do.
Cheers,
Michi.
Follow ups
References