on CONSUME_CLICK
Hello
I have a code like this
-------------
class HellWorldScreen extends form {}
...
public HellWorldScreen (string pageTitle, String btnLabel, track int, hell obj) {}
....
Tattoo = new MyButton (btnLabel, track, obj);
Add (myButt);
}
}
...
private class MyButton extends ButtonField implements {FieldChangeListener}
...
Public MyButton (String btnLabel, track int, hell obj) {...}
' Public Sub fieldChanged (field field, int context) {...}
...
}
...
so, how can I use CONSUME_CLICK here
I did private button class so I cudn set CONSUME_CLICK
Please help me
in your constructor, call the constructor of super with the parameter "style."
Super (btnLabel, ButtonField.CONSUME_CLICK)
Tags: BlackBerry Developers
Similar Questions
-
How do CONSUME_CLICK on a LabelField?
Hello
I listed suruneliste of names I used LabelField to display names. Now, I want to open a popup when the user clicks the labelfield. I can't find CONSUME_CLICK to use for LabelField. How to achieve it. ? I've already implemented navigationClick.
The code so far I coded is:
public static LabelField getClickableLabelField(String label) { LabelField lb = new LabelField(label, Field.FOCUSABLE | Field.FIELD_LEFT | Field.FIELD_VCENTER ) { public void paint(Graphics g){ g.setColor(Color.WHITE); super.paint(g); } protected boolean navigationclick(int status, int time) { fieldChangeNotify(1); return true; } }; return lb; } IN THE IMEPLEMENTING CLASS : LabelField lf = Common.getClickableLabelField(nm); lf.setCookie(new Integer(i)); lf.setChangeListener(this); public void fieldChanged(Field field, int context) { if (field instanceof LabelField) { LabelField lf = (LabelField) field; // Wanted to check if this is the correct field or not if (lf.isFocus()) System.out.println("YES HAS FOCUS, CORRECT ONE !!! Text = " + lf.getText()); } return; }
Can anyone help me know how to get the clicked labelfield and fieldNotify is called, and therefore the implementation class fieldChanged().
Any help is very appreciated.
Thank you
Override navigationUnclick() to always return true.
-
Hi all.
I posted this question before in http://supportforums.blackberry.com/t5/Java-Development/how-to-prevent-occurrence-menu-when-click-a-... but as a thread how on an issue different from the original. Given this is not connected somehow and a problem in itself, I decided to start a new thread. Forgive me if I'm wrong. I'll appreciate a response in one of the two sons
I have a button that poped a menu when you click on it and going through the forums I found the solution of CONSUME_CLICK style. In fact, the menu popup more but it gave me an undesirable side effect
Now, it happens that when I put the focus programmatically withbutton.setFocus (, the tracks of methodFieldChangeListener.fieldChange automatically producing unexpected click
I tried to read the context value, but it is always zero
How to avoid the popup menu AND the automatic one click when button.setFocus () is called
I've seen this behavior in my Curve 8520 with v.5.0.0.1036. Simulators v.6.0 as 9300 and 9800 running don't behave this way. They do not have the auto click
What happens if you just remove the earpiece of change of field (by calling setChangeListener (null)) before you call setFocus() and place it back after that called setFocus?
-
The Menu appeared on a touchevent click an EditField. CONSUME_CLICK is not an option to the edit field.
He always did, but I still have to figure out what caused change to happen. Maybe because I went to GridFields. Anyone has any ideas on how to avoid that the menu when I use a touchscreen device and click the EditField?
Thank you!
When you override navigationUnclick, return false - return super.navigationUnclick (status, time). It is a cleaner way to do it and it saved my day several times.
-
Style CONSUME_CLICK does not work
Work on a device application that will access to specific internet sites using URLS encoded in hard from the user by clicking on the buttons.
So far, I've not had handling actual button clicks because the CONSUME_CLICK style is ignored and I get the Dialog.inform box appears when I close the application, if I clicked on one of the buttons.
If one of you could advise what I left out or reported wrongly, I would be very happy.
Here is the code:
(First screen of the application
package com.avwx.ui;
Import net.rim.device.api.ui.UiApplication;
SerializableAttribute public class AvWxApp extends UiApplication {}
public AvWxApp() {}
Screen AvWxMainScreen = new AvWxMainScreen();
pushScreen (mainScreen) ;}
Public Shared Sub main (String [] args) {}
AvWxApp app = new AvWxApp();
app.enterEventDispatcher ();
}}
(Second screen of the application
package com.avwx.ui;
Import net.rim.device.api.ui.Field;
Import net.rim.device.api.ui.FieldChangeListener;
Import net.rim.device.api.ui.container.MainScreen;
Import net.rim.device.api.ui.component.ButtonField;
Import net.rim.device.api.ui.container.HorizontalFieldManager;SerializableAttribute public class AvWxMainScreen extends form {}
public AvWxMainScreen() {}
ButtonField SSECButton;
ButtonField SFCWXButton;
ButtonField PROG12Button;
ButtonField PROG24Button;
ButtonField PROG36Button;
ButtonField PROG48Button;SSECButton = new ButtonField ("HSEC", ButtonField.CONSUME_CLICK);
SFCWXButton = new ButtonField ("SFC WX", ButtonField.CONSUME_CLICK);
PROG12Button = new ButtonField ("PRG12", ButtonField.CONSUME_CLICK);
PROG24Button = new ButtonField ("PRG24", ButtonField.CONSUME_CLICK);
PROG36Button = new ButtonField ("PRG36", ButtonField.CONSUME_CLICK);
PROG48Button = new ButtonField ("PRG48", ButtonField.CONSUME_CLICK);HorizontalFieldManager buttonManager = new HorizontalFieldManager (FIELD_LEFT);
buttonManager.add (SSECButton);
buttonManager.add (SFCWXButton);
buttonManager.add (PROG12Button);
Add (buttonManager);HorizontalFieldManager buttonManager1 = new HorizontalFieldManager (FIELD_LEFT);
buttonManager1.add (PROG24Button);
buttonManager1.add (PROG36Button);
buttonManager1.add (PROG48Button);
Add (buttonManager1);}
}Style CONSUME_CLICK works fine, but it has nothing to do with the popup you see.
You get the context menu when you close a form that has one or more components that have been modified, it is marked 'Dirty'. She asks what you want to do with the changes. Type in a text field, or click a button is examples of things that mark a 'dirty' component
CONSUME_CLICK said the button that should not pass the event click on the field from its parent once the listener has run. Click makes the 'dirty' button regardless of if the button uses the click.
You can add NEVER_DIRTY to your style of button, instead of or in addition to CONSUME_CLICK. Then the click will not set the 'dirty' flag and you won't get the popup. You can decide later if you need to deal with buttons dirty another way, as in the listener, or substituting onSave or onSavePrompt, as mentioned in RexDoug.
-
Implementation of a CONSUME_CLICK in a TreeField
I want that when I touch or press enter on my TreeField the menu freaking do not appear, any ideas? I'm just now trying to substitute the touch and Navigation but event it gives me problems. so I wonder if anyone knows...
Hi, the plugin of blackberry have a pack of examples, there, you should check SQLiteDemo, in this example, you will find all the methods you need.
Sorry for my English.
-
A screen popup menu is opened after the closure of the dialog box
Hello
I have a test application with a screen containing a button.
When I click on the button (pressing the button on my BlackBerry 9220 trackpad), it opens a dialog box.
Then when I press ESC to my BlackBerry 9220, it closes the dialog box and I'm back on my screen.
Now, if I add to my screen, a menu item, the changes in behavior:
When I click on the button (pressing the button on my BlackBerry 9220 trackpad), it opens a dialog box.
Then when I press ESC to my BlackBerry 9220, it closes the dialog box and opens a menu screen.
So, I would add my item of menu but keeping the old behavior of my application after you close the dialog box.
Any idea?
Thank you.
Best regards.
Here is the code:
Import net.rim.device.api.ui.UiApplication;
Import net.rim.device.api.ui.component.ButtonField;
Import net.rim.device.api.ui.component.Dialog;
Import net.rim.device.api.ui.container.MainScreen;
Import net.rim.device.api.ui.Field;
Import net.rim.device.api.ui.FieldChangeListener;
Import net.rim.device.api.ui.MenuItem;
Import net.rim.device.api.util.StringProvider;
SerializableAttribute public class TestApplication extends UiApplication
{
public TestApplication()
{
this.pushScreen (new TestScreen());
}
Public Shared Sub main (String [] args)
{
Application TestApplication = new TestApplication();
application.enterEventDispatcher ();
}
}
final TestScreen class extends FieldChangeListener implements screen
{
public TestScreen()
{
/ * MyMenuItem MenuItem = new MenuItem (new StringProvider ("my menu item"), 0 x 230000, 0); * /
ButtonField myButtonField = new ButtonField ("button my field");
myButtonField.setChangeListener (this);
This.Add (myButtonField);
/ * this.addMenuItem (myMenuItem); * /
}
' Public Sub fieldChanged (field field, int context)
{
Dialog.Alert ("test");
}
}Here are a few screenshots:
It comes from the popup menu. create the button with CONSUME_CLICK would be the simplest solution.
-
How display the precedent when the browser shut down.
Hi all
I'm working on an application where user opens a screen and click a button when the user pressed this button, that it redirects to the browser of the phone with a specified binding. but I am facing a problem in that, when finally narrow the user's browser without complete specific action, my screen also poped off the coast of the user interface. My concern is that if the user close or close the browser without end action it must show previous screen. Please suggest me how to do this...
Here is the code
ButtonField checkUpdate = new ButtonField ("Update", ButtonField.CONSUME_CLICK);
FieldChangeListener updateListener = new FieldChangeListener() {}
' Public Sub fieldChanged (field field, int context) {}Private private = Browser.getDefaultSession ();
browserSession.displayPage ("http://www.xyz.com");}
};
checkUpdate.setChangeListener (updateListener);
Some clarifications are needed before answering the question.
requestBackground() is launched against the running application, not a screen. If the application that will be 'requestBackground()' is your application (unless you did something very complicated!). If you call requestBackground() in your application, then the BlackBerry OS will put your application at the bottom of the application stack and use the application stack that I described earlier to decide who to display screen of the application.
In your application (in fact in any application), there is only a single screen at a time. The BlackBerry OS keeps a stack of screen for your application, so the top of the screen hides those below. When the screen from the top is popped, the one below is displayed.
Now, back to your question:
"can we set several background screen using the requestBackground() method?"
I hope you understand now my answer, that is, you can set screens of your application in the background - but in reality, from the point of view of the user, you send a screen in the background, since that's all they see (users) don't see not the other displays on screen of the application stack until the top is popped.
-
HY everybody, I am creating a Blackberry application and I created a LabelField with text and I want to make a button in the same row with the text, but I don't know how to do this.
Here is the code:
public StakeMenu() {}
LabelField game = new LabelField ("chicken stock", Field.FIELD_LEFT);
Add (stake);
HorizontalFieldManager buttonManager = new HorizontalFieldManager (Field.VISUAL_STATE_ACTIVE);
ButtonField add = new ButtonField ("Add", ButtonField.CONSUME_CLICK);
buttonManager.add (add);
Add (buttonManager);
}Unfortunetly my code puts the button under the text, but I want to be on the same line with it. Please help me!
From your code, I think that you don't really understand BlackBerry Ui - which is not surprising given that you are new to the platform. So I suggest general information on unemployment insurance and the field of reading. The Java micro site contains information that will be useful, for example this:
http://developer.BlackBerry.com/BBOS/Java/documentation/managers_1969899_11.html
I suggest as you advance through the whole site - leanring not everything but to find where is the useful documentation:
http://developer.BlackBerry.com/BBOS/Java/documentation/
Once you have done this, I think you will then fall into the trap others fell when the labels and buttons at the side. So if you have any problems with it, then use the search (see above right) field to find the questoins that others have asked and solved.
-
HY everybody, I am a beginner in the development of Blackberry, and I am trying to create a button that when pressed, she goes to another screen. I have no idea how to proceed, could someone help me with an example or something I can use as a starting point?
Hello
Try this:
ButtonField btn = new ButtonField ("press me", ButtonField.CONSUME_CLICK);
btn.setChangeListener (new FieldChangeListener() {}' Public Sub fieldChanged (field field, int context) {}
UiApplication.getUiApplication () .pushScreen (new nextScreen());
}
});
This.Add (BTN);Thank you
-
Want to change the position of the button
I use HorizontalFieldManager and it it I add 2 buttons 'Add' and 'sub '. So I need to position Center butttons
How, how to perform the positioning of the button
You can do this using the method the HorizontalFieldManager setMargin().
Something like:
ButtonField btnAdd = new ButtonField("Add", ButtonField.CONSUME_CLICK); ButtonField btnSub = new ButtonField("Sub", ButtonField.CONSUME_CLICK); HorizontalFieldManager btnManager = new HorizontalFieldManager(); int leftMargin = (Display.getWidth() - btnAdd.getPreferredWidth() - btnSub.getPreferredWidth())/2; btnManager.setMargin(0, 0, 0, leftMargin); btnManager.add(btnAdd); btnManager.add(btnSub);
Concerning
Bika
-
Avoid the popup on click ButtonField
Hey guys, rite, I've been looking for centuries now, and the problem I have is that I can't seem to stop the popup to appear, I looked through the forums and although there are a lot of things tell me how to do it, none of them seem to actually tell me how to stop the menu go up when I click on a button.
I can get the menu to not appear, but then the button does not work.
Its getting on my nerves now cus its pretty well the last thing I have to do on the entire application.
Thanks in advance
Howard
Add CONSUME_CLICK to the style of the ButtonField.
-
HY guys, I have created a few buttons on a screen, and I want that they also to appear in the menu.
Here's a buton
ButtonField myButton = new ButtonField ("Push me", ButtonField.CONSUME_CLICK);
myButton.setChangeListener (new FieldChangeListener() {}
' Public Sub fieldChanged (field field, int context) {}
UiApplication.getUiApplication () .pushScreen (new AnotherScreen));
}
});addMenuItem (_viewItem);
And here's the menu function. This function simply displays a message. But I want to put my button here and have the same function (to send me to another screen). Cand how so? Do I have to declare the new button in this function?
_viewItem private MenuItem = new MenuItem ("", 110, 10)
{
public void run()
{
Dialog.Inform ("Hello");
}
}Thanks in advance
I understand it. In the run method I rechangés Dialog.inform ('Hello'); with UiApplication.getUiApplication () .pushScreen (new AnotherScreen));
I posted the solution thinking that somene else encounter this problem.
-
How to make a button than increse value
HY guys, I want to make two buttons which when they press increse or decrese value that one Eurorest between them. The value I guess must be in a list. But I have no idea how to make a list of numbers and, more important still, how to add the feature to increase value to the buttons. I use Blackberry 5.0
I know as tot creata a button for this:
ButtonField increase is new ButtonField ('increase', ButtonField.CONSUME_CLICK);.
Add (increase);Can someone help me? If you can give me an example of code, I'd really apreciate.
If your list is to be static, you can set up a table, for example with an int]
If you want the list to be dynamic (in size), you can use a vector. It is only necessary to objects, you should encapsulate your numbers in a class. For int which is whole.
In your form (or), you can store the index of the currently selected number. When you click the button, you increase the index with + or - and load the new value of the vector/matrix.
-
HY huys, I do an application that allows a user to connect and after it connects it shows the user name.
Here's the code that display the user name when the user logs on:
public LoginSuccessScreen (String username, String selectedDomain) {}
Add (new LabelField ("" Looged in! "'));
Add (new LabelField ("username:" + username));I made a button called back that sent me to the previous screen, but it does not show the username more
Here is my back button:
ButtonField back = new ButtonField ("Back", ButtonField.CONSUME_CLICK);
back.setChangeListener (new FieldChangeListener() {}
' Public Sub fieldChanged (field field, int context) {}
UiApplication.getUiApplication () .pushScreen (new LoginSuccessScreen (null));
}
});I know that the problem is that I put null in the LogginSuccessScreen, but if I left it emty he displays an error.
Can anyone tell me what it takes to display the user name when I push the back button or al, less is the right way to make a button that sends you to the previous screen?
Thanks in advance
generally, you use a battery of screens. If you come back you just pop the top and another below.
If you want to display the LoginSuccessScreen you will have to give the parameters he wants. Maybe you can store them somewhere and add them in the fieldChanged method?
Maybe you are looking for
-
Cannot get mail that failed to connect to my server
Cannot get mail Failed to connect to my server
-
How to use the personal style polifonoc in a partition?
Hello community, In Logic 9, I used to combine 2 flutes in 1 staff and used personal style polifonic when they played different roles. How logic X? Thanks in advance.
-
Half left of my screen LCD on Satellite P30 suddenly became black.
I scoured the internet for info on how to fix and I have not been successful. From what I found, I think the 17 "display using 2 backlight. If this is the case of the point at which the black part and a part of work would be so sudden... I mean this
-
Structure of the event in the event structure
Is it possible that I can have a structure of the event, which is in another structure of the event? When I run the code, I can't use other buttons. (See chart for details)
-
Create custom codes such as on any other computer user doesn't have to manually add all files
I'm developing an application where all the sub screws must use the error of the master vi where vi master generates a custom error. Sub screws could base their action according to what a mistake he has received. What is the best way to define custom