fieldchangelistener shot by mistake on Edit fields

Hi people,

I use the RIM JDE 4.2.1 on windows and the 8800 Simulator.  I install a fieldchangelistener on an edit field to detect the moment where I should be offering save a screen.  But the listener is shot before any changes to the screen are made... This is the expected behavior?  Here is an example of code to the constructor of the screen:

private static class AllFieldChangeListener implements FieldChangeListener {
    public void fieldChanged(Field field, int context) {
        isDirty = true;


FieldChangeListener myListener = new AllFieldChangeListener();


I look in the debugger, the fieldchangelistener shot (watch where isDirty is true) at the time where this form is drawn: the referenced field is above edit field (in fact I have several fields on the screen and for each/all triggers are being fired once for each edit field).  I've done this kind of thing before for the checkbox fields set up by program the enabled or disabled state of the button and the listener does not until such time as the user interacts with the screen.

I am puzzled, someone has an idea what I am doing wrong?

Thanks for any help.



Field changes listener will be called even if you set the text programmatically. To ignore the changes programattiic check that the context is not equal to FieldChangeListener.PROGRAMMATIC

private static class AllFieldChangeListener implements FieldChangeListener {
    public void fieldChanged(Field field, int context) {
           if(field == myeditField && context != FieldChangeListener.PROGRAMMATIC) {
        isDirty = true;

BTW why you set isDirty using this method? You can simply use nameField.isDirty () to check if the field is dirty when you want.

Tags: BlackBerry Developers

Similar Questions

  • Get the text in the Edit field


    In my Application, I add a check box and a label field and a field change a grid field Manager. Then this network domain manager, I add several times in Vertical field Manager. So it's looking like list of items. Now, when I checked the box five, trying to get the text of the corresponding edit field.

    This is the code for the domain network manager:

    int c[] = {screenWidth/6, (screenWidth)/3, (screenWidth)/2};
            gm = new GridFieldManager(c, Manager.VERTICAL_SCROLL);
            Logger.out("Grocery", "Here it is coming"+i);
            cbfChecked = new CustomCheckBoxField();
            cbfChecked.setChangeListener(new FieldChangeListener()
                public void fieldChanged(Field field, int context)
                    if(checked[i] == false)
                        checked[i] = true;
                    else if(checked[i] ==  true)
                        checked[i] = false;
                        Logger.out("Grocery", "It is UnChecked" +checked[i]);
            Logger.out("Grocery", "Adding first Label Field");
            LabelFieldCustom lfFrom = new LabelFieldCustom((String) m_vtrItems.elementAt(i),Color.BROWN,FONT_FAMILY_0_SF_AS_16,Field.FIELD_LEFT);
            Logger.out("Grocery", "Adding second Label Field");
            efcAmount = new EditFieldCustom(Bitmap.getBitmapResource("dob_text_box.png"), 25);
            efcAmount.setMargin(new XYEdges(30, 0, 0, 0));
            return gm;

    Here I add the grid domain manager several times:

    for (int i = 0;i < m_vtrItems.size();i++)
                vfm.add(new SeparatorField(SeparatorField.NON_FOCUSABLE));

    Here is the snapshot of my screen:

    Please help me.

    You can access the field by index (prone to errors if).
    or you could save your fields in a data structure, such as a hash table, with the checkboxfield as key to the editfield as value.

  • Non editable field change to highlight the problem

    Hi all

    I have an edit non editable field in my screen. In order to make the difference between editable and non editable field, I put the bottom of the field cannot be changed to light gray as in the code below:

       Border nonEditableBorder=BorderFactory.createRoundedBorder(new XYEdges(5, 5, 5, 5),Color.LIGHTGRAY,Border.STYLE_FILLED|Border.STYLE_TRANSPARENT);
    EditField textField=new EditField(EditField.NO_NEWLINE|EditField.FOCUSABLE|DrawStyle.RIGHT);

    Now the field cannot be changed when I scroll the wheel to the right or left the text gets highlighted in white as shown in the image below:

    I don't want the text to highlight. Can anyone help me please with this. Thanks in advance.

    Kind regards

    S.A.Norton Stanley


    Thank you. Overridding method drawFocus() and nothing doing, emphasis has been disabled on the fields and the white highlight was not. But once I reached the first or the last field of the white selection screen gets drawn again.  But the border I also assign the background of the field edit as shown below, and this solved my problem.

    Background bgNonEditable = BackgroundFactory.createSolidBackground(Color.LIGHTGRAY);
  • Is not scrolling screen when the virtual keyboard is opened by clicking an edit field


    I have searched and tried many things, but not got success.

    There are three managers of verticalfield in my screen.



    = new VerticalFieldManager(Manager.USE_ALL_WIDTH |) Manager.USE_ALL_HEIGHT | Manager.NO_VERTICAL_SCROLL) {}

    protected voidpaint (Graphics grphcs) {}

    if (imgBG! = null) {

    grphcs.drawBitmap (0, 0,

    imgBG.getWidth (), imgBG.getHeight (), imgBG, 0, 0);


    Super.paint (grphcs);


    protected void sublayout (int maxWidth, maxHeight int) {}

    maxWidth = UIConstants.


    maxHeight = UIConstants.


    Super.sublayout (maxWidth, maxHeight);

    Super.setExtent (maxWidth, maxHeight);





    = new VerticalFieldManager(Manager.USE_ALL_WIDTH |) Manager.USE_ALL_HEIGHT | NO_VERTICAL_SCROLL) {}

    protected voidpaint (Graphics grphcs) {}

    if (imgBGCoverInternetHome! = null) {

    grphcs.drawBitmap ((UIConstants.

    SCREEN_WIDTH - imgBGCoverInternetHome.getWidth () / 2, 0, imgBGCoverInternetHome.getWidth (), imgBGCoverInternetHome.getHeight (), imgBGCoverInternetHome, 0, 0);


    Super.paint (grphcs);


    protected void sublayout (int maxWidth, maxHeight int) {}

    maxWidth = UIConstants.


    maxHeight =

    imgBGCoverInternetHome.getHeight () / *-UIConstants.SCREEN_HEIGHT (UIConstants.LABEL_HEIGHT + UIConstants.FOOTER_MENU_HEIGHT) * /;

    Super.sublayout (maxWidth, maxHeight);

    Super.setExtent (maxWidth, maxHeight);





    = new VerticalFieldManager(USE_ALL_WIDTH |) USE_ALL_HEIGHT | VERTICAL_SCROLL) {}

    protected void sublayout (int maxWidth, maxHeight int) {}

    maxWidth = UIConstants.


    maxHeight =

    imgBGCoverInternetHome.getHeight () - imgButtonFocusBig.getHeight (/2/*UIConstants.SCREEN_HEIGHT - (UIConstants.LABEL_HEIGHT + (UIConstants.FOOTER_MENU_HEIGHT + VERTICAL_GAP))) * /;

    Super.sublayout (maxWidth, maxHeight);

    Super.setExtent (maxWidth, maxHeight);



    I'm addidng all fields in the Manager of scrolling that is vfmScroll.

    By clicking on the edit field, virtual keyboard opens on the screen, change the field leathers and screen does not scroll.

    Help, please.

    Thanks in advance.

    Thanks for the reply of Peter. Instead of UIConstants.SCREEN_HEIGHT, now I use Display.getHeight () - headerHeight-footerHeight. Given that Display.getHeight () is calculated accordingly when the virtual keyboard is open, so his works well for me.

  • How to paste text in ANY editable field (e-mail, sms, browser, contacts address bar / any other application)


    Can anyone help me please with the following questions:

    1. once I have add a menu item to help

    ApplicationMenuItemRepository.getInstance().addMenuItem(ApplicationMenuItemRepository.MENUITEM_SYSTEM, myMenuItem);

    I am able to access an instance of net.rim.blackberry.api.mail.Message (when I'm in the e-mail editing mode) and put the content in the subject / body of the email, but it was mostly a proof of concept for me.

    What I really want to be able to do, it's automatically access the instance of any editable field in any (RIM / part 3) app that the user cursor is now. When the focus is on something that is not editable, then my menu item should not appear in the menu.

    In addition, it is important for me to know exactly where the cursor is. For example if the cursor is in the middle of the text, then I want that my extraordinary paste paste of stuff there. The same for the selected text - it needs to be replaced.

    Basically I want my menu Paste Special feature works exactly like 'Stick', unless I want to offer which should be pasted.

    2. Apart from curiosity, what are we supposed to go back to the

    public Object run(Object context)

    method? For now, I'm doing my treatment based on the type of control context and make the treatment on it and everything just return null (which works well), but I don't know I'm on some features.

    Never done this, but looking at the API and remembering what simon_hain said when asked a similar question, I think it goes like:

    You can get help from the active screen

    UiApplication.getUiApplication () .getActiveScreen ();

    You can get the Menu for a screen to help

    . getMenu();

    You can browse the menu for help

    . getItem()


    . getSize()


    I think that 'toString' will give you the message, then

    . Run()

    to run it.

  • Edit field change notify pop up


    How to avoid the pop-up screen which appears when editing field does not appear in the screen

    How to avoid this pop up screen?


    Add this to your screen:

    * Override to ignore the save/discard/Cancel dialog box
    public boolean onSavePrompt() {}
    Returns true;

    Not wanting to be rude, but I recommend looking in the forum before asking the question.  This question has been asked and answered several times in the past and I suspect you would have found if you had looked.  Ok?

  • How can I set the width of the part of the label of an edit field?

    Anyone know how I can configure the width of the part of the label of an edit field?  that is, I want to have my line to edit until a fixed width field labels.

    It is not possible to set the width of the part of the label of an editfield.

    In this case, you can use a LabelField with fixed width (the substitution of layout() method) and an EditField and add then both a HorizontalFieldManager.



  • Custom edit field - not drawing while typing of the text

    I created a custom edit field (code below), but there is no slider or text drawn while typing.

    The text appears if you click another field on the screen, but not while typing. I guess it has something to do with my method of painting, but I don't know?

    Tips for making more effective methos painting would be a bonus!

    Thank you!

    import net.rim.device.api.system.Display;
    import net.rim.device.api.ui.Font;
    import net.rim.device.api.ui.FontFamily;
    import net.rim.device.api.ui.Graphics;
    import net.rim.device.api.ui.component.EditField;
    public class CustomTextField2 extends EditField {
        private int fieldWidth;
        private int fieldHeight;
        private int button_colour = 0xF9F9F9;
        private int text_colour = 0x666666;
        private int border_color = 0xCCCCCC;
        private Graphics graphics = null;
        public CustomTextField2(long arg0) {
            fieldWidth = Display.getWidth()-100;
            //int off = 8;
            FontFamily fFam = null;
            try {
                fFam = FontFamily.forName("SomeFontHere");
            catch (ClassNotFoundException e) {
            Font font = fFam.getFont(Font.PLAIN, 20);
            Font defaultFont = font;
            int off = 8;
            fieldHeight = defaultFont.getHeight() + off + 10;
            this.setPadding(5, 20, 5, 20);  }
        protected void paint(Graphics graphics) {
            graphics.fillRect(0, 0, fieldWidth, fieldHeight);
            graphics.drawRect(0, 0, fieldWidth, fieldHeight);
            graphics.drawText(this.getText(),20,10/2);               super.paint(;
        protected void onFocus(int direction) {
            button_colour = 0xF9F9F9;
            text_colour = 0x666666;
            border_color = 0x3598CC;
        protected void onUnfocus() {
            button_colour = 0xF9F9F9;
            text_colour = 0x666666;
            border_color = 0xCCCCCC;
        protected void drawFocus(Graphics graphics, boolean on) {
              super.drawFocus(graphics, on);
        protected void fieldChangeNotify(int context)
            try {
            this.getChangeListener().fieldChanged(this, context);
            catch (Exception e){
        public int getPreferredHeight() {
            return fieldHeight;
        public int getPreferredWidth() {
            return fieldWidth;
        protected void layout(int arg0, int arg1) {
            setExtent(getPreferredWidth(), getPreferredHeight());

    I just posted a code in another thread - he does most, if not all, of what you want. Take a look:

    Custom elegant EditField (textbox)

  • Text of tip/guest/space reserved on a digital editing field / password

    Hi all

    I am introducing the rapids/tips for the edit fields text in my application. I capture the key in the api keyChar() and therefore

    • show the cue text if the field is empty
    • hide the cue already displayed text when the first character is entered

    According to me, one way to do this is to paint your index directly on the EditField.  This way, the EditField never sees.  And you can paint it in a light color to indicate clearly what is not actually entered.

    Here is an example of code, note that I cut/pasted it from a working application, but changed a few things that I think are not - but it could have messed up it completely...

    private BasicEditField _searchField = new BasicEditField ("", "") {}
    String emptyString = "search by input characters;
    Protected Sub paintBackground (Graphics g) {}
    g.setBackgroundColor (0x00FFFFFF);
    g.Clear ();
    protected void paint (Graphics g) {}
    oldColor int = g.getColor ();
    try {}
    g.setColor (0x00000000);
    Test string = super.getText ();
    If (test == null | test.length ())< 1="" )="">
    g.setColor (0 x 00808080);
    g.drawText (emptyString, 0, 0);
    Super.Paint (g);
    } {Finally
    g.setColor (oldColor);

  • Menu appears on touchevent click EditField. CONSUME_CLICK is not an option to the edit field.

    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.

  • Editable fields dialog box

    Hi, I created a dialog box with a BasicEditField but when I run the app I can't enter alphanumeric data in the edit field.

    Anyone see where I was wrong?

    BasicEditField _orderno = new BasicEditField ("Order #:", "", 10, BasicEditField.FIELD_LEFT |) BasicEditField.EDITABLE);
    ObjectListField _orderList = new ObjectListField(ObjectListField.USE_ALL_HEIGHT |) ObjectListField.USE_ALL_WIDTH);

    public SetOrderNumberDialog()
    Super (null "Define the order number", null, 0, My.mLogo, Field.FOCUSABLE |) Field.FIELD_HCENTER);
    Add (new SeparatorField());
    Add (_orderList);
    Add (new SeparatorField());
    _orderList.setSelectedIndex (0);
    Add (_orderno);

    Sorry my fault. I guess I overide the keyChar() and that is why any touches of character have been accepted.

  • In the edit field

    Hi all

    can someone help me in editing field, enter text when the field width fill then is not to go to the next line.its decerese fontsize and decrese... time to come when the font size of text would be constant.i do customize edit field and override the paint method in this... How to set the size of police... so that his decrese when full field width and text do not go in the following line


    thx a lot its work for me

  • How can I send a document by e-mail in PDF with editable fields, drop-down boxes and check boxes?

    Our company uses Adobe Reader as well as the version where send you it for signature, convert to word, excel etc.

    What we are trying to do, however, is create the PDF document, save it to our readers of local network for use in a format PDF with editable fields, drop-down boxes to select and check boxes.

    Can you help me please?

    See you soon


    Hi lucindab50782713,

    Yes, you can save the document as a model using eSign service create a library template | services eSign so that it can be reused.

    Kind regards

  • I need to create a PDf form with specific editable fields, including the ability to insert an electronic signature and to be able to save the completed form. What version of adobe supports this?

    I need to create a PDF form with specific editable fields, including the ability to insert an electronic signature and to be able to save the completed form. What version of adobe supports this?

    subscription dc Acrobat or purchase, Plans and prices | Adobe Acrobat DC

  • Displacement of editable fields too long.

    I need to change a form of 4 pages full of editable fields. Because the original is in English and I need to change to the Spanish text, all boxes need to be moved. But it takes forever just to move one box. Is this something to do with the version? I use Acrobat Pro/Distiller 10.1.10 (windows). The original is the Standard Version 1.6 and the Spaniards is 1.4 (I have no idea what it is). What I usually do is open to English PDF, save a copy, replace pages with the Spanish and start editing the boxes already provided with English PDF. Can someone help me? Thank you!

    Acrobat 11 is the only version with the preference that I mentioned. It can solve the problem you are having, but you haven't really explained what the problem is. I just guess at the cause, but there is a good chance of being wrong.

Maybe you are looking for

  • With Chrome, I can and print or save pages or pages. in format PDF. How in Firefox?

    for example. If a document has 6 pages I print or save to PDF format, some or all pages.I use a 6560 probook, Professional 64 bit, windows so I PDF without using PDF Complete, which is the only choice for PDF in the print file.

  • Connection WLan C855-1TG - Win 8 - satellite of abandonment

    I recently bought a Toshiba laptop with Windows 8... It's a Satellite C855-1TG.I have repeated drop offline from my Orange Live box. My old lap top with XP, my Ipad & Android phone have no such problems.Looking at internet forums it seems to be a com

  • How entry NaN in LV8.5

    I'm trying to turn empty waveform to make a chart seem to have 2 different colors, but I can't seem to enter NaN in my paintings.  I tried to use positive infinity, 1/0 and NaN in a digital constant, but they are all defaults to ~ 2.25E9.  If not, ho

  • E5-571 and startup issues

    Have just got a E5-571 and thought id look at updates after updating to windows 7 10 I searched by serial number and saw that the bios is outdated if updated as suggested - the bios was the one suggested by acer. On upgrade, it started and told me th

  • KB2532531 of security for Windows Vista Sp2 update

    Windows update keeps trying to install security update KB2532531 for Windows Vista Sp2, but installation is never complete and the changes are returned. The automatic update becomes irritating as it regularly tries to force the reboot of my machine a