Oops, here's the code!
Place these to receive messages from searchbar and from the menu:
Code:
kindle.messaging.receiveMessage('searchBarButtonSelected', callbackFunction);
kindle.messaging.receiveMessage('systemMenuItemSelected', callbackFunction);
Use this to setup searchbar and menu (add and set any button you want for the searchbar and any item in the menu. Just replicate the structure...)
Code:
function setupChrome () {
var json = {
"appId": "yourAppId",
"searchBar": {
"clientParams": {
"profile": {
"name": "yourProfile",
"buttons": [
{
"id": "buttonID",
"state": "buttonState",
"handling":"buttonHandling"
}
]
}
}
},
"systemMenu": {
"clientParams": {
"profile": {
"name": "default",
"items": [
{
"id": "store",
"state": "hidden",
"handling":"system",
"label":"The damn store",
"position":0
},
{
"id": "yourFirstMenuItem",
"state": "buttonState",
"handling":"buttonHandling",
"label":"yourFirstMenuItem",
"position":1
},
{
"id": "yourSecondMenuItem",
"state": "buttonState",
"handling":"buttonHandling",
"label":"yourSecondMenuItem",
"position":2
}
],
"selectionMode": "none",
"closeOnUse": true
}
}
}
};
kindle.messaging.sendMessage('com.lab126.pillow', 'configureChrome', json);
}
I found that the Kindle loves to show the store in menu.
So, adding it in first position and hiding it is useful...
This is the callbackFunction:
Code:
function callbackFunction (property, json){
if ((property == 'searchBarButtonSelected') && (json == 'yourFirstSearchbarItem')){
}
if ((property == 'searchBarButtonSelected') && (json == 'yourSecondSearchbarItem')){
}
if ((property == 'systemMenuItemSelected') && (json == 'yourFirstMenuItem')){
}
if ((property == 'systemMenuItemSelected') && (json == 'yourSecondMenuItem')){
}
}
Searchbar items can be (depending on the layout you choosed before):
Code:
buttons: {
back: 'back',
store: 'store',
home: 'home',
forward: 'forward',
menu: 'menu',
refresh: 'refresh',
cancel: 'cancel'
},
States can be:
Code:
buttonStates: {
enabled: 'enabled',
disabled: 'disabled',
hidden: false
},
while you can choose either to handle it yourself or not:
Code:
buttonHandling: {
system: 'system',
notifyApp: 'notifyapp'
}
MenuItems are referenced using their Id.