Flash required to explore WidSets
The newest version of the Flash Player is required to explore WidSets. Please download and install the free Flash Player from the icon below.
After installation, refresh this page »
Soft Buttons Problem
Soft Buttons Problem
Hi all, I have a problem where in that the soft buttons are not doing what I want them to, using a variation of if, if else or case i get the result that the soft buttons either do the same thing as each other, both buttons do both functions or the buttons do nothing, what follows is my code, can any one shed any light on this...
class
{
const int CMD_BACK = 1;
const int CMD_OK = 1;
const String URL = "http://www.nofussreviews.com/widsets.php";
MenuItem OK = new MenuItem(CMD_OK, "Search");
MenuItem BACK = new MenuItem(CMD_BACK, "Back");
void startWidget()
{
setMinimizedView(createMinimizedView("viewMini", getStyle("default")));
}
Shell openWidget()
{
final String STORE = "input.text";
Flow content = new Flow(getStyle("default"));
content.setFlags(VISIBLE|LINEFEED);
content.setPreferredSize(-100, -100);
Store store = getStore();
String text = store.has(STORE)? String(store.getValue(STORE)) : "Enter game name";
Input input = new Input(getStyle("input"), "Your text", text, ANY);
input.setFlags(VISIBLE|FOCUSABLE|LINEFEED);
input.setPreferredWidth(-100);
content.add(input);
final Shell shell = new Shell(content);
//HyperText ht = new HyperText(getStyle("maxi"));
//ht.setPreferredWidth(-100);
//ht.appendMarkup("hyper.", "<p>hello world</p>");
//fetch();
return shell;
}
void fetch()
{
//http parameters to be used in get-query
Value params = [
"gamename" => "mario"
];
//widsets http service parameters
Value arg = [
"url" => URL,
"params" => params
];
call(null, "httpService", "get", arg, ok, nok);
}
void ok(Object state, Value ret)
{
setBubble(null, ret);
//printing html to log
}
void nok(Object state, String error)
{
setBubble(null, "Http get failed: "+error);
}
MenuItem getSoftKey(final Shell shell, final Component focused, final int key)
{
if (key == SOFTKEY_OK) {
return OK;
} else if (key == SOFTKEY_BACK) {
return BACK;
}
return null;
}
void actionPerformed(final Shell shell, final Component source, final int action)
{
if (action == CMD_OK) {
fetch();
} else if (action == CMD_BACK) {
popShell(shell);
}
}
}
Re: Soft Buttons Problem
const int CMD_BACK = 1;
const int CMD_OK = 1;
Actions with a same action code cannot be identified.
