Blackberry popup menu appear on Button click event - blackberry

I have a problem that popup menu appear when I click a button field. I will solve it by using Buttonfield.consumeclick but it also appears on RichTextField focus. How can I solve this? I am overriding RichTextField method, and that is the reason the popup menu appears.

ButtonField c = new ButtonField("button", FIELD_LEFT | ButtonField.CONSUME_CLICK) {
protected boolean navigationClick(int status, int time) {
Status.show("Button has clicked");
// write your code.
return true;
}
}

Related

Handling Touch EventListener in presence of navigationClick()

In application, Whenever i move bewteen tabs a full menu, copy, switch application pop up open.
To prevent this i override navigationClick method.
Now pop is not shown. In my second tab i have implemented drop down list. Because i have override navigationClick method when i click on drop down list it is not showing me list of items.
Any idea will be apperciated.
Update:
Here is navigationClick implementation:
public boolean navigationClick(int status, int time) {
return true;
}
Make sure while selecting a tab, no errors occur which probably could be the reason for the menu options to pop up. if this is fixed i guess the subsequent problem will be dissolved!
Out of my experience i have observed the menu pops up in blackberry when a NullPointerException event occurs.
Just check the logs or debug to make sure no exception occurs when you navigate between tabs
If you want to click the labelfield then:
LabelField labelField=new LabelField("Click")
{
protected boolean navigationClick(int status, int time)
{
doLabelFieldClicked();
return true;
}
}
and if Menu option is highlighted then override this:
public boolean onMenu(int instance)
{
return true; //It doesn't show the Menu option.
}
If I am thinking wrong let me know.
I solved this problem by implementing navigationClick() while creating lablelField
tab5 = new LabelField("News", LabelField.FOCUSABLE | LabelField.HIGHLIGHT_SELECT)
{
public boolean navigationClick(int status, int time)
{
return true;
}
};

Menu key not working in popupscreen

there is PopupScreen in my application .. PopupScreen have some Field like BasiceditTextfield and Buttonfield .
when i click on my BasiceditTextfield virtual keyboard open automatically in my 9550 Storm but when i click on Device Menu key nothing happen. i cant hide virtual keyboard ..
how to hide that .?
Use this.
This will enable Menuscreen and disable back key of the device.
protected boolean keyDown(int keycode, int status)
{
if(keycode==1769472)
{
return true;
}
else
{
return false;
}
}

Can i call dialog box on popup screen in blackberry?

In my blackberry application i make one popup screen which is popup on click of menu item. on that popup screen i took one button. Now i want to show alert dialog box on click of that button.How to do this ?Plz tell me.
You can do like this.
public void fieldChanged(Field field, int context)
{
if(field.equals(your button object))
{
Dialog.alert("Your message");
}
}

hiding menu on click

I am using NullField() in one of my screen so that the default focus should not be on any of the button . but when i am clicking on the screen where no field is there , menu screen is being displayed. i dont want that menu screen to be poped up tough it should open when i click menu button.
Thanks alot
override method.
protected boolean navigationClick(int status, int time) {
Field focus = UiApplication.getUiApplication().getActiveScreen()
.getLeafFieldWithFocus();
if (focus instanceof NullField) {
return true;
}
return super.navigationClick(status, time);
}
Note:This code is only for giving you hint.

How could i avoid the SAVE dialog in my custom blackberry Application?

I am writing a blackberry application and pushing screens one after another(three in series)
Screen1 displays Screen2 and Screen2 displays Screen3
When i press "Back Key" on my Blackberry Device i.e., bold 9700, its prompts a dialog box with Question mark image and buttons "Save" "Discard" "Cancel".
Why does this dialog appears?
How can i avoid this dialog?
Please Help
Thanks
SIA
you can avoid this type of dialog by overriding onClose method for that screen :
public boolean onClose()
{
this.close();
return true;
}
There are two ways of doing this:
Override the isDirty() method of your Screen (via: Blackberry - Disable Save option in BasicEditField?):
public boolean isDirty() { return false; }
You can also override the onSavePrompt() method of your Screen (also via: Blackberry - Disable Save option in BasicEditField?):
protected boolean onSavePrompt() { return true; }
Simply Write this code in your specified class:
protected boolean onSavePrompt()
{
return true;
}
It will disable the Save Prompt Dialog Box.

Resources