fieldchangelistener

When I put tell listener as objectchoicefieldlistener it works 5n...

Lst FieldChangeListener = new FieldChangeListener() {}
' Public Sub fieldChanged (field field, int context) {}

try {}
        
If {(field instanceof field)
    
ObjectChoiceField tt = field (ObjectChoiceField);
String str = (String) tt.getChoice (tt.getSelectedIndex ());
UiApplication.getUiApplication () .pushScreen (new prac (str));
   
}
    
}
{} catch (ClassCastException (e)
e.printStackTrace ();
}
  
}
};

I select an option frm objectchoicefield n control jumps 2 form d n poster select next value...

but when I implement say same listener for buttonfield instead of objectchoicefield for control of tht jumps 2 next screen aftr I click the button... It work... n y?

Hello

try using the following code

public void fieldChanged(Field field, int context) { if(field == bn)   {      String str =(String)choicefiled.getChoice(choicefiled.getSelectedIndex());            UiApplication.getUiApplication().pushScreen(new prac(str));           }

       }

Tags: BlackBerry Developers

Similar Questions

  • TouchEvent & FieldChangeListener both does not work

    Hello

    I have 2 bitmapfields and a buttonfield. I want that all fields to intercept the click event. Initially, I had added only fieldChangeListeners to all fields, but bitmap field has not answered them (despite making them Focusable). I added touchevent to handle events click for all areas, now all fields respond only touchEvents. Same buttonfield does not meet fieldChange that he met before adding the touchEvent.

    Can someone help me to know the problem and the solution for the same. I want that all fields to react to events through contact or normal by a click. Also in touchEvent as navigationClick added id, if the menu is not coming, but otherwise with the other menu click only just who should not and the fieldchangelistener should be handled.  Here's the code.

        private BitmapField  signOffBtn, profileBtn;
        private ButtonField btn;
    
        public LoggedUserScreen(UserBean user) {
            super();
            this.loggedUser = user;
            System.out.println("Into LoggedUserScreen : Got user");
            init();
            this.add(signOffBtn);
            this.add(profileBtn);
            this.add(btn);
        }
    
        private void init() {
            signOffBtn = new BitmapField (Bitmap.getBitmapResource("icon.png"),  BitmapField.FOCUSABLE ) {
                protected boolean navigationClick(int status, int time) {
                    return true;    // handle click event
                }
            };
            profileBtn = new BitmapField (Bitmap.getBitmapResource("icon.png"),  BitmapField.FOCUSABLE ) {
                protected boolean navigationClick(int status, int time) {
                    return true;    // handle click event
                }
            };
            btn = new ButtonField("button", BitmapField.HIGHLIGHT_SELECT |  BitmapField.FOCUSABLE);
            signOffBtn.setChangeListener(this);
            profileBtn.setChangeListener(this);
            btn.setChangeListener(this);
        }
    
        public void fieldChanged(Field field, int context) {
            if (field == signOffBtn) {
                System.out.println("********* SIGN OFF CLICKED");
            } else if (field == profileBtn) {
                System.out.println("********* PROFILE CLICKED");
            } else if (field == btn) {
                System.out.println("********* button CLICKED");
                System.exit(0);
            }
        }
    
       public int getFieldAtLocation(int x, int y)    {
             XYRect rect = new XYRect();
             int index = getFieldCount() -1;
             while (index >= 0)        {
                getField(index).getExtent(rect);
                if (rect.contains(x, y))
                    break;
                 --index;
             }
             return index;
      }
    
      protected boolean touchEvent(TouchEvent event) {
    
          switch(event.getEvent()) {
              case TouchEvent.DOWN:
                return true;
              case TouchEvent.MOVE:
                return true;
              case TouchEvent.UP:
                return true;
              case TouchEvent.CLICK:
                int index = getFieldAtLocation(event.getX(1), event.getY(1));
                // Ignore click events outside any fields
                if (index == -1)
                    return true;
    
                Field field = getField(index);
                if (field == signOffBtn) {
                    System.out.println("Touched SignOff");
                } else if (field == profileBtn) {
                    System.out.println("Touched Profile");
                } else if (field == btn) {
                    System.out.println("Touched Button");
                }
                return true;
          }
          return false;
      }
    

    Thank you

    Ago I already watched this about such removeFocus or setFocus (false) or more. But yes, your something.setFocus gave me the idea to setFocus on the screen itself for the development is removed from the key also and not on any component capable of intercepting the event.

    So if I add fieldChangeNotify (0); in signOffBtn navigationclick, profileBtn & btn, then I totally don't need to implement the touchEvent?

        private void init() {
            signOffBtn = new BitmapField (Bitmap.getBitmapResource("icon.png"),  BitmapField.FOCUSABLE | ButtonField.FIELD_LEFT) {
                protected boolean navigationClick(int status, int time) {
                    fieldChangeNotify(0);
                    return super.navigationClick(status, time);    // handle click event
                }
            };
            profileBtn = new BitmapField (Bitmap.getBitmapResource("icon.png"),  BitmapField.FOCUSABLE | ButtonField.FIELD_RIGHT ) {
                protected boolean navigationClick(int status, int time) {
                    fieldChangeNotify(0);
                    return super.navigationClick(status, time);    // handle click event
                }
            };
            imageBtn = new ImageButton(Bitmap.getBitmapResource("icon.png"), Bitmap.getBitmapResource("icon.png"));
            btn = new ButtonField("button", BitmapField.HIGHLIGHT_SELECT |  BitmapField.FOCUSABLE | ButtonField.FIELD_RIGHT) {
                protected boolean navigationClick(int status, int time) {
                    fieldChangeNotify(0);
                    return super.navigationClick(status, time);    // handle click event
                }
            };
    
            signOffBtn.setChangeListener(this);
            profileBtn.setChangeListener(this);
            imageBtn.setChangeListener(this);
            btn.setChangeListener(this);
        }
    

    touchEvent is totally deleted & navigationClick is implemented for each button.

    Thank you. I just want to confirm, with this, my componetns everything will work for touch & non touch screen properly. 9530 Simulator touch screen reacts (left mouse click), but not touch that is a click (muose right clisk) does not do anything. So I was wondering...

  • FieldChangeListener does not not in OS6

    I have the following listener to perform an action to a button click event.  It works very well in OS5 devices, but nothing happens when you click the button in the OS6 devices.  Any ideas?

    ButtonField buttonSearch = new ButtonField("Search", ButtonField.CONSUME_CLICK)
            {
                public int getPreferredWidth()
                {
                    return Display.getWidth();
                }
            };
            FieldChangeListener listener = new FieldChangeListener() {
                public void fieldChanged(Field field, int context) {
                    final AddressInfo addrInfo = new AddressInfo();
    
                        addrInfo.setField(AddressInfo.STREET, street.toString());
                        addrInfo.setField(AddressInfo.CITY, city.toString());
                        addrInfo.setField(AddressInfo.STATE, state.toString());
                        addrInfo.setField(AddressInfo.POSTAL_CODE, postal.toString());
                        addrInfo.setField(AddressInfo.COUNTRY, "United States");
                    geoCache(addrInfo);
                }
            };
            buttonSearch.setChangeListener(listener);
            add(buttonSearch);
    

    try to use this code: I use it on OS 6.0

    class xxxxxx extends MainScreen implements FieldChangeListener{    xxxxxx()    {        ButtonField buttonSearch = new ButtonField("Search", ButtonField.CONSUME_CLICK);        buttonSearch.setChangeListener(this);    }
    
        public void fieldChanged(Field field, int context)     {        if (field == buttonSearch)         {        }    }}
    
  • FieldChangeListener for the custom field does not...

    Hi all

    I searched for him and almost all positions tried but failed to get the solution of it. Here is my code. My problem is when I click on the individual images the fieldchangelistener must be called and the message.

    package com.samples;
    
    import net.rim.device.api.ui.Field;
    import net.rim.device.api.ui.FieldChangeListener;
    import net.rim.device.api.ui.Manager;
    import net.rim.device.api.ui.component.Dialog;
    import net.rim.device.api.ui.container.MainScreen;
    import net.rim.device.api.ui.container.VerticalFieldManager;
    
    public class CustomPaintingScreen extends MainScreen implements FieldChangeListener
    {
        CustomClass[] custom;
    
        FieldChangeListener itemlistener = new FieldChangeListener() {
    
            public void fieldChanged(Field field, int context)
            {
                Dialog.alert("clicked");
            }
        };
    
        public CustomPaintingScreen()
        {
            setTitle("Custom Painting ");
            custom = new CustomClass[10];
            VerticalFieldManager vfm = new VerticalFieldManager(Manager.VERTICAL_SCROLLBAR|Manager.LEAVE_BLANK_SPACE);  
    
            for (int i = 0; i < custom.length; i++)
            {
                custom[i] = new CustomClass();
                custom[i].setChangeListener(itemlistener);
                vfm.add(custom[i]);
            }
            this.add(vfm);
        }
    
        public void fieldChanged(Field field, int context)
        {
            if(field instanceof CustomClass)
            {
                Dialog.alert("clicked");
            }
        }
    }
    

    and here's my customclass

    package com.samples;
    
    import java.util.Vector;
    import net.rim.device.api.system.Bitmap;
    import net.rim.device.api.system.Display;
    import net.rim.device.api.ui.Color;
    import net.rim.device.api.ui.Field;
    import net.rim.device.api.ui.Font;
    import net.rim.device.api.ui.Graphics;
    import net.rim.device.api.ui.XYRect;
    
    public class CustomClass extends Field //implements FieldChangeListener
    {
        private XYRect dest;
        private Bitmap bitmap;
        private Vector vtr;
        private Bitmap next;
    
        public CustomClass()
        {
            bitmap = Bitmap.getBitmapResource("laptop.png");
            next = Bitmap.getBitmapResource("next.png");
            dest = new XYRect(20,15,bitmap.getWidth(),bitmap.getHeight());
            //this.setChangeListener(this);     
    
            vtr = new Vector();
        }
    
        protected void layout(int width, int height)
        {
            height = getFont().getHeight()* 5;
            setExtent(Display.getWidth(), height);
        }
    
        protected void paint(Graphics graphics)
        {
            graphics.setColor(0xFF7F24);
            graphics.fillRoundRect(5, 5, (getWidth()-10), (getFont().getHeight()*5), 30, 40);
            graphics.drawBitmap(dest, bitmap, 0, 0);
            graphics.setColor(Color.BLACK);
            int x = bitmap.getWidth()+25;
            int y = 15;
            graphics.setFont(getFont().derive(Font.BOLD));
            graphics.drawText("Dell Laptop", x, y, 0, getWidth());
            graphics.setFont(getFont().derive(Font.PLAIN,15));
    
            String str= "Discover Dell Inspiron and XPS Laptops with advanced technology.this is dell laptop";
            vtr = wrap(str, 300,graphics);
            System.out.println(" "+vtr.toString());
    
            graphics.drawBitmap(335, 15, next.getWidth(), next.getHeight(), next, 0, 0);
    
    //      graphics.drawText(vtr.toString(), x, (y+20), 0,300 );
        }
    
        private Vector wrap (String text, int width,Graphics graphics)
        {
            int x = bitmap.getWidth()+25;
            int y = 35;
    
            Vector result = new Vector ();
            if (text == null)
               return result;
    
            boolean hasMore = true;
    
            // The current index of the cursor
            int current = 0;
    
            // The next line break index
            int lineBreak = -1;
    
            // The space after line break
            int nextSpace = -1;
    
            while (hasMore)
            {
               //Find the line break
               while (true)
               {
                   lineBreak = nextSpace;
                   if (lineBreak == text.length() - 1)
                   {
                       // We have reached the last line
                       hasMore = false;
                       break;
                   }
                   else
                   {
                       nextSpace = text.indexOf(' ', lineBreak+1);
                       if (nextSpace == -1)
                          nextSpace = text.length() -1;
                       int linewidth = this.getFont().getAdvance(text,current, nextSpace-current);
                       // If too long, break out of the find loop
                       if (linewidth > width)
                          break;
                   }
              }
              String line = text.substring(current, lineBreak + 1);
    
              graphics.drawText(line, x, y, 0,350 );
              y=y+15;
    
              result.addElement(line);
              result.addElement(new String("\n"));
              current = lineBreak + 1;
         }
         return result;
        }
    
        protected boolean navigationClick(int status, int time)
        {
            fieldChangeNotify(1);
            return super.navigationClick(status, time);
        }
    
        protected void fieldChangeNotify(int context)
        {
            super.fieldChangeNotify(context);
        }
    }
    

    also my images look like this

    When I click on the individual images, the dialog box should appear. I tried a lot of things. give me a code. for screen touch for example jde4.7 and jde4.5

    Hi peter - what did I want to add the listener on the image above and manipulate. and the picture above, I created using the graphics object. so this is the question that I am able to get the listener?

  • First choice in ObjectChoiceField do not call FieldChangeListener.

    Hello everyone, I have a choice of object field to display a list of the cities. I gave the initial value for field as the first city in the list of cities. I put the changes for the field and hadling the event listener using fieldChanged().

    I use getSelectedIndex() to treat the choice more far. When I choose choice other than the first (0th position choice), it works fine. But when I choose the first, nothing happens. I debugged n saw that control comes not at all to the fieldChanged() method.

    My code is as below:

    mCityDropDown.setChangeListener (new FieldChangeListener() {}
                
    ' Public Sub fieldChanged (field field, int context) {}
                    
    if(Context == 0) {}
    return;
    }
    UiApplication.getUiApplication () .invokeLater (new Runnable() {}
                            
    public void run() {}
    Dialog.Inform ("Index:" + mCityDropDown.getSelectedIndex ());

    }
    });

    }

    });

    Can anyone tell if I am wrong somewhere n suggest me the solution. Thanks in advance.

    The default value of the change listener, it fires if something is changed.
    as the index is 0 before AND after there is no change.
    You must adapt your application logic to that.

  • Question about FieldChangeListener

    Finally, I'm going back to rewrite the custom PopupScreen that I created for a blackberry app staff.

    I had a question on a FieldChangeListener I set myself for a button.

    The code looks like this:

    FieldChangeListener fcl = new FieldChangeListener()
    {
      public void fieldChanged(Field field, int context)
      {
        fieldChangeNotify(cancel) //cancel is a public static final int
        close();
      }
    };
    
    ButtonField.setChangeListener(fcl);
    

    My question is this: how to retrieve the context of int fieldChangeNotify (int context) value if the listener is attached to the key?

    I am tempted to write a method that mimics the method getSelectedValue() of the dialog class.

    I just wrote to follow him, not production code, but I need something similar to what you want (a dialog box I could put things in).  I hope you can use it, and it shows you how to enable a button in a return code.

    Note that the questionField is optional, basically, the idea is that this screen will be used when it is necessary to confirm an action and collect additional information.  You can ignore it.

    Here is an example of using the screen - I have; ve just done upwards, so please forgive the errors:

    BasicEditField _questionField = new BasicEditField ("reason for Deferring:", "");
    Create the popup to confirm the defer
    ConfirmActionPopupScreen caps = new ConfirmActionPopupScreen ("Confirm Report", _questionField);
    int response = caps.doModal ();
    If (int ==-1) {}
    cancelled
    } else {}
    Oudit
    String pattern = _questionField.getText ();
    ...
    }

    And here is the screen.  Note that I had to change a few things that are specific to what I do, so it would not work, but you get the idea.

    I hope it works for you.

    class ConfirmActionPopupScreen extends PopupScreen
                                   implements FieldChangeListener {
    
        private ButtonField _okButton = new ButtonField("OK");
        private ButtonField _cancelButton = new ButtonField("Cancel");
        private BasicEditField _questionField = null;
    
        private int _returnCode = -1; // Default to Cancel value
    
        //statics ------------------------------------------------------------------
        private static ResourceBundle _resources = ResourceBundle.getBundle(UIResource.BUNDLE_ID, UIResource.BUNDLE_NAME);
    
        public ConfirmActionPopupScreen(String confirmString, BasicEditField questionField) {
            super(new VerticalFieldManager(),Field.FOCUSABLE);
            // Question Icon and text on top
            HorizontalFieldManager hfm = new HorizontalFieldManager();
            hfm.add(new BitmapField(Bitmap.getPredefinedBitmap(Bitmap.QUESTION), BitmapField.FIELD_LEFT));
            hfm.add(new LabelField(" ")); // Just to space it a bit
            hfm.add(new RichTextField(confirmString, RichTextField.FIELD_HCENTER | RichTextField.FIELD_VCENTER ));
            this.add(hfm);
            this.add(new SeparatorField());
            // Optional Question
            _questionField = questionField;
            if ( _questionField != null ) {
                this.add(_questionField);
                this.add(new SeparatorField());
            }
            // Buttons at bottom
            hfm = new HorizontalFieldManager(Field.FIELD_HCENTER);
            hfm.add(_okButton);
            _okButton.setChangeListener(this);
            hfm.add(_cancelButton);
            _cancelButton.setChangeListener(this);
            add(hfm);
    
            // Focus on Question or Cancel Button
            if ( _questionField != null ) {
                _questionField.setFocus();
            } else {
                _cancelButton.setFocus();
            }
        }
    
        /**
         * Diaplay this Screen and wait for response
         * @return indicator of selected button
         */
        public int doModal() {
            UiApplication.getUiApplication().pushModalScreen(this);
            return _returnCode;
        }
    
        /**
         * Only used to process ESC as Cancel
         */
        public boolean keyChar(char key, int status, int time) {
            //intercept the ESC key - exit the app on its receipt
            boolean retval = false;
            switch (key) {
                case Characters.ESCAPE:
                    _returnCode = -1;
                    close();
                    return true;
            }
            return super.keyChar(key,status,time);
        }
    
        public void close() {
            UiApplication.getUiApplication().popScreen(this);
        }
    
        /**
         * Listen for Button press, and process accordingly.>
         */
        public void fieldChanged(Field field, int context) {
            if ( context == FieldChangeListener.PROGRAMMATIC ) {
                return;
            }
            if ( field == _cancelButton ) {
                _returnCode = -1;
                close();
            } else
            if ( field == _okButton ) {
                if ( _questionField != null ) {
                    // Make sure there is some data entered
                    String temp = _questionField.getText();
                    if ( temp == null || temp.length() < 1 ) {
                        Status.show("Input required, please update \"" + _questionField.getLabel() + "\"");
                        _questionField.setFocus();
                        return;
                    }
                }
                _returnCode = 0;
                close();
            }
        }
    
    }
    
  • ObjectChoiceField FieldChangeListener problem

    Hi all

    I'm coding an application for 4.5 but testing on BB 9500.

    I want to a few call webservice on the choice of an ObjectChoiceField.

    But the problem is that the FieldChangeListener of the ObjectChoiceField fires on the development as well as on the selection of the field.

    How to distinguish two event?

    Thaks for your help in advance.

    Hi all

    I found the solution to my problem.

    Below is sample code for the solution.

    ObjectChoiceField myObjectField= new ObjectChoiceField("",new String[] { "" }, 0, FIELD_LEFT)
    {
        protected void fieldChangeNotify(int context)
        {
        new myObjectField_change_method();
        }
        public void focusChangeNotify(int arg0)
        {
        super.focusChangeNotify(arg0);
        }
    };
    

    In the code above myObjectField_change_method() is a method to be triggered when the field is selected.

  • BitmapField FieldChangeListener problem

    Hello

    I use BitmapField as a button with the two FieldChangeListener and

    FocusChangeListener in my application.

    In FocusChangeListener I change just image of bitmapfield

    and in FieldChangeListener, I gave a single action.

    Problem is when BitmapField won the development, called FieldChangeListener

    What could be the solution to prevent this?

    I want action to call only to click and not on the FOCUS_GAINED event

    Hello

    Instead of domain change listener tries with method "click browsing..."

    ----------------------------------------------------------------------------------------------------------------------------------------------------------

    Press 'Congratulations' if it helps

  • ObjectChoiceField and FieldChangeListener

    I'm creating an application (Storm 9530 component package 4.7) that uses an ObjectChoiceField which is filled by anywhere from 1 to 50 choice programming.  I would use the FieldChangeListener to generate a new pop-up screen based on the selection made by the user of the ObjectChoiceField.  Because the list can be quite long, the user may need to scroll the list to find their choice.  Each time the selection is changed in the FieldChangedListener is called, but I want only to take action in the final selection is made ("clicked").  I have been in charge of the search and search but have not found the key to understand the current state of the ObjectChoiceField (open or closed).  Any help would be greatly appreciated.

    TIA,

    Tim

    You will not be able to differentiate between these types of changes within a FieldChangeListener.  Instead, you might have the user selects an entry and use a ButtonField or MenuItem to check their choice.  Or you could have your action occur when the focus is moved out of the ObjectChoiceField.

  • FieldChangeListener for a GridFieldManager element

    Hello

    I have a GridFieldManager loaded with lots of elements in the horizontalFieldManagers type. I noticed after you add managers to GridFieldManager and appellant getFieldAtIndex to my GridFieldManager, she will return me a FIELD. Can I put a FieldChangeListener to the returned field? What I know is that I couldn't do it at HorizontalFieldManager. But I can do this returned field?

    My intention is to create a list, whenever you click on one of the elements, it will change the content of the gridfieldmanager.

    Thank you very much!

    Yes, but BitmapFields does not normally change so don't do not normally call the change listener.  You need to implement yourself for the field.  It's easy, substitute navigationClick and touchEvent.  There are many examples on this forum looking for an Image button.

  • FieldChangeListener - should work, but it is not

    public class TestDynamicMenus extends MainScreen implements FieldChangeListener {
        ButtonField btOK;
        public TestDynamicMenus () {
            ButtonField btOK = new ButtonField ("OK", ButtonField.CONSUME_CLICK);
            btOK.setChangeListener(this);
            add(btOK);
        }
    
        public void fieldChanged(Field field, int context) {
            if (field == btOK){
                Dialog.inform("Hi");
                }
        }
    }
    

    It drives me crazy - button shows in the Simulator, but nothing happens when I push it. What I am doing wrong?

    Hello

    Just change:

    ButtonField btOK = new ButtonField ('OK', ButtonField.CONSUME_CLICK);

    TO

    btOK = new ButtonField ('OK', ButtonField.CONSUME_CLICK);

  • FieldChangeListener for AutoCompleteField does not work - question

    I just took a default value AutoCompleteField and set a fieldChangeListener, but debugging found that fieldChanged (...) never gets invoked. This has happened to 7.0 and BB 5.0,6.0. Anyone know why?

    However, FocusChangeListener work.

    I mean you can overwrite
    http://www.BlackBerry.com/developers/docs/7.0.0api/NET/rim/device/API/UI/component/AutoCompleteField... int)

  • CheckboxField [] and fieldChangeListener.

    Hello

    I need a dynamic number of checkboxes for a project I'm working on. My code example is as follows. Somehow, I get an jvm stackoverflow exception.

    public class abc() extends screen implements {FieldChangeListener}

    CheckboxField [] boxField;

    public abc() {}

    .

    .

    .

    the length is variable.

    boxField = new CheckboxField [length];

    VFM VerticalFieldManager = new VerticalFieldManager();

    for (int i = 0; i)

    boxField [i] = new CheckboxField();

    boxField [i] .setChangeListener (this);

    VFM. Add (boxField [i]);

    }

    Add (VFM);

    }

    Sub fieldChanged (field field, int context) {}

    Hardcode for now. The intention is to loop through and uncheck all

    except one who was just ticked.

    chkBoxField [0] .setChecked (false); StackOverflow exception

    }

    }

    Help?

    In this way:

    chkBoxField [0] .setChecked (false);

    You set the value of the checkbox, prompting to advise its FieldChangeListener, which is to set the value of the box, which advises the FieldChangeListener... I could go on.   Until what I stack overflowed of course.

    Although there are many ways to stop this, I think that you should be aware of using the context provided to the fieldChanged method.  To check

    FieldChangeListener.PROGRAMMATIC

    If it matches, then the change was made by a program and not by the user, in which case you should ignore the change.

    For example:

    Sub fieldChanged (field field, int context) {}

    If (context == FieldChangeListener.PROGRAMMATIC) {}

    Only to process user changes to checkboxes

    return;

    }

    .....

    Hope it makes sense.

    Edit: this has been creating during the validation of RexDoug, my apologies for the repetition.

  • Paint screen on fieldchangelistener

    Hi all

    I'm having a little hold with a question. I would like to paint a new image based on the selection made by the user to the screen (selection is made by an ObjectChoiceField). I'm sure that this is possible, I don't know what code to use. Could someone please help on this issue.

    Thanks in advance.

    Configure your FieldChangeListener on your ObjectChoiceField.

    FieldChanged, call your code to paint your image on the screen and then invalidate. It all depends on how you paint this picture on the screen.

  • 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;
        }
    }
    
    nameField.setText(options.names[idx]);
    
    FieldChangeListener myListener = new AllFieldChangeListener();
    nameField.setChangeListener(myListener);
    
    add(nameField);
    

    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.

    -Scott

    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.

Maybe you are looking for