FuseJS/Shortcut Module (JS)
This module allows you to shows menu items when pressing App Icon on the device home screen. This feature refer to the home screen actions on iOS and App Shortcut on Android (introduced in Android 7.1 / API Level 25).
You need to add a reference to "Fuse.Shortcut"
in your project file to use this feature.
This module is an EventEmitter, so the methods from EventEmitter can be used to listen to events.
Usage
The following example shows how create shortcut:
<App>
<JavaScript>
var Observable = require("FuseJS/Observable")
var selectedShortcut = new Observable("-")
var shortcut = require("FuseJS/Shortcut");
shortcut.registerShortcuts([
{
id: 'compose',
title: "Compose",
icon: "assets/images/compose.png"
},
{
id: 'profile',
title: "Profile",
icon: "assets/images/user.png"
},
{
id: 'book_store',
title: "Book Store",
icon: "assets/images/book.png"
}
])
shortcut.on('shortcutClicked', (type) => {
selectedShortcut.value = type;
})
module.exports = {
selectedShortcut
}
</JavaScript>
<StackPanel Margin="20">
<Text Value="Selected Shortcut: {selectedShortcut}" />
</StackPanel>
</App>
Note that on the `registerShortcuts` method accepts array of json objects with the following properties:
* id, id of the shortcut, and will be passed on the `shortcutClicked` callback when particular shortcut get clicked. This property is mandatory
* title, to display menu title. This property is mandatory
* subtitle, to display sub title (displayed below the title on iOS). This property is optional
* icon, to display icon beside the menu title, value of the icon is a local image path (i.e asset path) not a url and must be registered as a Bundle. More info about Bundle [here.](/docs/assets/bundle). This property is optional
Location
- Namespace
- Fuse.Shortcut
- Package
- Fuse.Shortcut 2.9.1
Interface of ShortcutModule
Inherited from NativeEventEmitterModule
Emit(object[]) uno
EmitError(string) uno
Call emit("error", reason)
on the underlying JS EventEmitter.
EmitErrorObject(string) uno
Call emit("error", new Error(reason))
on the underlying JS EventEmitter.
EmitFactory(Func<Context, object[]> (Context)) uno
EmitFactory<T>(Func<Context, T, object[]> (Context, T), T) uno
On(object, Callback (Context, object[])) uno
Connect a Callback to an event.
On(object, NativeEvent) uno
Inherited from NativeModule
AddMember(NativeMember) uno
Reset : EventHandler (object, EventArgs) ux
Inherited from Module
Dispose uno
Evaluate(Context, ModuleResult) uno
Evaluate(Context, string) : ModuleResult uno
Evaluated : EventHandler (object, EventArgs) ux
EvaluateExports(Context, string) : object uno
GetFile : FileSource uno
Returns the file source that will be watched by the Context for changes in Fuse preview. Override in subclasses and return correct file source to support live updates in Fuse preview.