setFocus problems

Hello

I'm trying to set the focus on a button in a given form. It seems that it should be as simple as using setFocus, but I'm getting IllegalStateException when setting the update on my custom button by button.setFocus)

is there something that I am missing?

Custom buttons are focusable, then in the custom button class, I added the method

{} public void setFocus()

super.setFocus ();

}

and the code short grand.

Thanks for your help!

Tags: BlackBerry Developers

Similar Questions

  • SetFocus problem with screen Page tabs

    Hi Blackberry guys,.

    I followed the base article of developers Blackberry How-to - create display tabbed screens

    a source of inspiration for my screen to the custom tab.

    I have to create the control tab with unlimited tabs as follows

    Tab1. Tab2. Tab 3. >>


    On >focusChanged, I remove Tab1 in horizontal Manager and add Tab4 and set the current focus to Tab4.

    But when I invoke the. setFocus() tab4; It throws NullPointerException

    Here's the event focusChanged for reference

    ' Public Sub focusChanged (field field, int eventType)
    {
    If (eventType is FOCUS_GAINED)
    {
    for (int i = 0; i)<>
    {
    (field is tabs [i])
    {
    Delete (tabPanel);
    tabPanel = getTabPanel (i);
    Add (tabPanel);
    return;
    }
    }
    if(Field == LabelNext)
    {
    tabs [nextTab] = getNextTab();
    hManager.add (tabs [nextTab]);
    Tabs [lastTab]. SetFocus();
    }
    }
    }

    Any idea of implementation of dynamic tabbed screen, would be much appreciated

    Thank you very much

    Pinsard

    Welcome to the forums!

    Try to encapsulate the setFocus() in invokeLater() - your focusChanged() is called within a chain of calls that surrounds a user interface event.  Leave (as well as the whole of the chain) finish and then issue the setFocus().

    Grabbing a lock of the event won't do any good - you're already on the event thread in your focusChanged method. You really need to let the frame to finish his work with the previous event before initiating a new. Which is why invokeLater() seems like the right way to go.

  • problem when using setFocus?

    Hello

    I have a problem in the use of setFocus in the text field.

    When I use setFocus it contains the definition slider to the textInput field, but until and unless if I click with the mouse its not take keyboard input!

    Let me know the solution ASAP

    Thanks and greetings

    Aruna.S.N.

    the best way to do this is to write a function small javascript in your HTML page (who will choose the appliction - as is the problem; cant flex focus on the field unless u click in the appliction if your browser has chosen it) - then call this function javascript of your flex application

    in flex.

    ExternalInterface.call("saveglobalscore",score) ('setBrowserFocus');

    usernametxt.setFocus ();

    in the html wrapper page

    function setBrowserFocus()

    {

    document.getElementById('${application}').focus ();

    }

    (when the application is the id of your embedded flex appliction)

    This approach works perfectly

  • xfa.host.setFocus (); beep problem

    xfa.host.setFocus (Expand); is placed below the text field. When cursore enters the field 'expand', a tone is created.

    How can I stop it?

    Hello

    All the sounds you hear using created LiveCycle Forms is sounds generated by your operating system - not PDFcreated and therefore not controlled by the authoring software. Sounds can be changed in the control panel - system sounds. There are no other ways to overcome what I know.

    I know that the fact that this has - I did not like it. However, I changed my sound Setup using a theme provided by Win7 and have a much more enjoyable experience. But all users can hear what they hear, according to the settings on their operating system. I have no control over this part of the user experience.

    Good luck!

    Stephen

  • Problem of control contextual element setfocus

    Hello!

    I use this construction.

    < TitleWindow >

    < s:Group >
    < mx:Form >
    < mx:FormItem >
    < s:NumericStepper id = "stepper" / >
    < / mx:FormItem >
    < / mx:Form >
    < / s:Group >
    < / s:TitleWindow >

    to display a popUp with PopUpManager.createPopUp etc.

    But, because NumericStepper (NS) is if with MXML, it does not exist in the display of TitleWindow's list (TW) when TW is ADDED_TO_STAGE.

    then, when I try to setFocus on NS in different ways (can be cpecific more if you need) when it is added to the stage, when it is added, TW or added_to_stage, etc..

    He reveals to crush Flash player or the error that ' «NS is not exist on stage, therefore cannot setFocus on it»»

    I need of setFocus() on NS when it appears, how can I do with this implementation of MXML?

    Please?

  • Move the focus from the listfiled to the particular label (horizontal scrolling problem)

    Hello

    In my application, I have some labels (which are focusable) at the top of the screen that I put in the manager (hfm_lbl) horizontal field with horizontal scrolling.

    After hfm_lbl, I have a listfiled.

    Now when I scroll to the top of the listfiled (i.e.from from bottom to top), the focus moves to top but sets the last menu of the hfm_lbl.

    I want the focus to specify the label of perticular.

    Any help is appreciated...

    Thank you...

    drawFocus won't help with this.

    The problem is only a HFM, when focus activates it by underneath, will automatically set the focus to the last item in the list.  Therefore, substitute this transformation.

    There are actually two options, depending on whether you want to override the onFocus method, or use a FocusChangeListener. I know that some people have had problems with the onFocus() substitution, so recommend the listener. But I never have, so after you will find a sample of the code that I use in this circumstance.

    The thing is that the treatment in the HFM should remember the lastFocusField (one of your labels) when the focus is moved there.  This challenge, I'll leave with you.  Still, he has a variety of options and not better.  So whatever you think probably will work fine.  One option is to set the HFM as a FocusChangeListener for all the domains that are added and then remember the last one, who won the point - then the treatment is autonomous in the HFM.

    The following codes assume that lastFocusField is a field in the HFM, one user had developed on before the ListField moved t.  This method overrides onFocus() in the HFM.

    protected void onFocus (int direction) {}
    super.onFocus (branch);
    If (direction! = 0 & lastFocusField! = null) {}
    UiApplication.getUiApplication () .invokeLater (new Runnable() {}
    public void run() {}
    lastFocusField.setFocus ();
    }
    });
    }
    }

    Edit: I think that Simon and I had to answer at the same time.  Just to say, in my experience in this case, you might be able to do it with moveFocus(), or navigationMovement(), but not as easily as onFocus().

  • Problem in the scroll bars when the screen is not any field focus...

    Hi all

    I have a screen on which I need to display a list of items. and the list total appears at the bottom of the list. everything works fine if the lily a few number of lines. but as soon as the number of rows and Lily exceeds the length of the screen, there is the problem. I don't see the total at the bottom because I can't scroll the list. Here is the code in my class. in the class list, I use a CustomGridManager, which shows data in a table (I downloaded it). I made a few changes in the present. the code for this handler is also attached. Please tell me what changes should I make, so that the screen can be the object of a scroll. (Please go through the code)...

    SerializableAttribute public class MyClass extends {screen

    public MyClass (dataList DataList []) {}

    Super(Manager.VERTICAL_SCROLLBAR |) Manager.VERTICAL_SCROLL);

    Super();

    int noOfColumns = 2;

    int noOfRows = dataList.length;

    int [] columnWidth = {50.50};

    CustomGridManager gfmHeader = new CustomGridManager (noOfColumns, 0, columnWidth);

    Adding headers

    LabelField lblHdrCol1 = new LabelField ("Col1");

    gfmHeader.add (lblHdrCol1);

    LabelField lblHdrCol2 = new LabelField ("Col2");

    gfmHeader.add (lblHdrCol2);

    VerticalFieldManager vfmTitle = new VerticalFieldManager();

    vfmTitle.add (new LabelField ("my class"));

    vfmTitle.add (gfmHeader);

    setTitle (vfmTitle);

    Addition of body

    GFM CustomGridManager = new CustomGridManager (noOfColumns, 0, columnWidth);

    for (int i = 0; i)< noofrows;="">

    LabelField lblICol1 = new LabelField (dataList [i] .getCol1 ());

    GFM. Add (lblICol1);

    LabelField lblICol2 = new LabelField (dataList [i] .getCol2 ());

    GFM. Add (lblICol2);

    Adding a footer

    CustomGridManager gfmFooter = new CustomGridManager (noOfColumns, 0, columnWidth);

    LabelField lblFtrTotal = new LabelField ("Total");

    gfmFooter.add (lblFtrTotal);

    LabelField lblFtrValue = new LabelField ("CalculatedValue");

    gfmFooter.add (lblFtrValue);

    Add (gfmHeader);

    Add (new SeparatorField());

    Add (GFM);

    Add (new SeparatorField());

    Add (gfmFooter);

    Add (new SeparatorField());

    }

    ======================================================

    SerializableAttribute public class CustomGridManager extends Manager {}

    private int [] columnWidths;

    private int [] staticColumnWidth;

    private int columns;

    private int allRowHeight = - 1;

    /**

    * Built a new CustomGridManager with the number of columns specified.

    * Lines will be added to the need to display the fields.

    * Fields will be added to the grid in the order they are added to this Manager.

    to complete each row from left to right:

    *

    * For example, a Manager 2 column:

    *

    * [Field1] [Field2]

    * [Field3] [Field4]

    * [Sphere5]

    *

    * Column widths are equal, and the Manager will attempt to use the entire available width.

    Each line height will be equal to the height of the field higher in the same row.

    * Styles positional field are met, then the fields that are smaller than the row/column

    * they can be set to left, right, up down, or centered. They have by default at the top left.

    *

    @param columns number of columns in the grid

    @param style

    */

    public GridFieldManager (columns int, long style) {}

    Super(Manager.VERTICAL_SCROLLBAR |) Manager.VERTICAL_SCROLL);

    Super (style);

    This.colonnes = columns;

    }

    /**

    *

    @param columns columns number of columns in the grid

    @param style

    @param columnWidths width of each column in a table

    */

    public GridFieldManager (columns int, long style, int [] columnWidths) {}

    Super(Manager.VERTICAL_SCROLLBAR |) Manager.VERTICAL_SCROLL);

    Super (style);

    This.colonnes = columns;

    this.staticColumnWidth = columnWidths;

    }

    protected boolean navigationMovement (int dx, int dy, int, int time status) {}

    int focusIndex = getFieldWithFocusIndex();

    While (dy > 0) {}

    focusIndex += columns;

    {If (focusIndex > = {getFieldCount())}

    Returns false; The focus moves on this manager

    }

    else {}

    Field f = getField (focusIndex);

    If (f.isFocusable ()) {/ / only move the focus on the fields of the object of focus}

    f.setFocus ();

    -DY;

    }

    }

    }

    While (dy< 0)="">

    focusIndex = columns;

    If (focusIndex< 0)="">

    Returns false;

    }

    else {}

    Field f = getField (focusIndex);

    If (f.isFocusable ()) {}

    f.setFocus ();

    DY ++;

    }

    }

    }

    While (dx > 0) {}

    focusIndex ++;

    {If (focusIndex > = {getFieldCount())}

    Returns false;

    }

    else {}

    Field f = getField (focusIndex);

    If (f.isFocusable ()) {}

    f.setFocus ();

    -DX;

    }

    }

    }

    While (dx< 0)="">

    -focusIndex;

    If (focusIndex< 0)="">

    Returns false;

    }

    else {}

    Field f = getField (focusIndex);

    If (f.isFocusable ()) {}

    f.setFocus ();

    DX ++;

    }

    }

    }

    Returns true;

    }

    protected void sublayout (int width, int height) {}

    int y = 0;

    columnWidths = new int [columns];

    If (staticColumnWidth == null: staticColumnWidth.length)<= 0)="">

    for (int i = 0; i)< columns;="" i++)="">

    columnWidths [i] = width/columns;

    }

    } else {}

    for (int i = 0; i)< columns;="" i++)="">

    columnWidths [i] = (width * staticColumnWidth [i]) / 100;

    }

    }

    On the field [] fields = Field [new columnWidths.length];

    currentColumn int = 0;

    rowHeight = 0 int;

    for (int i = 0; i)< getfieldcount();="" i++)="">

    fields [currentColumn] = getField (i);

    layoutChild (fields [currentColumn], columnWidths [currentColumn], height-y);

    If (fields [currentColumn] .getHeight () > rowHeight) {}

    rowHeight = fields [currentColumn] .getHeight ();

    }

    currentColumn ++;

    {If (currentColumn == columnWidths.length | I == {getFieldCount () - 1)}

    int x = 0;

    If (this.allRowHeight > = 0) {}

    rowHeight = this.allRowHeight;

    }

    for (int c = 0; c)< currentcolumn;="" c++)="">

    long fieldStyle is fields [c] .getStyle ();.

    int fieldXOffset = 0;

    long fieldHalign = fieldStyle & Field.FIELD_HALIGN_MASK;

    If (fieldHalign == Field.FIELD_RIGHT) {}

    fieldXOffset = columnWidths [c] - fields [c] .getWidth ();

    }

    Else if (fieldHalign == Field.FIELD_HCENTER) {}

    fieldXOffset = (columnWidths [c] - fields [c] .getWidth ()) / 2;

    }

    int fieldYOffset = 0;

    long fieldValign = fieldStyle & Field.FIELD_VALIGN_MASK;

    If (fieldValign == Field.FIELD_BOTTOM) {}

    fieldYOffset = rowHeight - fields [c] .getHeight ();

    }

    Else if (fieldValign == Field.FIELD_VCENTER) {}

    fieldYOffset = (rowHeight-fields [c] .getHeight ()) / 2;

    }

    setPositionChild (fields [c], x + fieldXOffset, y + fieldYOffset);

    x += columnWidths [c];

    }

    currentColumn = 0;

    y += rowHeight.

    }

    If (y > = height) {}

    break;

    }

    }

    totalWidth int = 0;

    for (int i = 0; i)< columnwidths.length;="" i++)="">

    totalWidth += columnWidths [i];

    }

    setExtent (totalWidth, Math.min (y, height));

    }

    }

    Do you really want now fields is active.

    You can try adding a NullField after your Manager - a NullField is active, if it does not size.

    Other than that, you can try the substitution of navigationMovement and Manager.setVerticalScroll to go up and down the window scrolling.  I think it should work, although I never did.  You can control the scope of the first Manager to ensure that you do not have to scroll through to the end.

  • Exception - called setFocus on a field that is not attached to a screen.

    I'll have a lot of areas in my screen. I'm trying to set the focus on the particular area. To do this, I use field.setFocus (). But it gives this exception

    setFocus call on a field that is not attached to a screen. But the field is added to the screen. I don't know what the problem is with me.

    How can I do this?

    Thanks for any help.

    Oh. I'm sorry. I resolve myself. I called this method until I added this field to display.

  • Problems with Knockoutjs &amp; webworks?

    I have a piece I've been debugging for the whole weekend and I just can't understand what is wrong with it. As far as I can see everything is as it should be. The HTML code I have is

    div class = 'networkItem' x-blackberry-Focus='true'=onmouseover "this.style.backgroundColor ='#444444 '; '=onmouseout" this.style.backgroundColor =' #010101 ";

    x onUp-blackberry-=' netNavUp ($index ()) ' x-blackberry-onDown=' netNavDown ($index ()).

    bind data = ' click: changeNetwork.bind ($data, no()), attr: {'id': 'nIf' + $index ()} ">".

    It is part of a foreach knockoutjs model. $index () is the index number 0 -? list

    the attr section creates an ID of this item to the nli0 format, nli1, nli2 etc. depends on County look.

    I can inspect the HTML code that it creates in the debugger chome and IDS are set correctly. And I suppose, at this stage, which is irrelevant in any case, as I have commented little bits in the code that woud use anyway. It seems that the call to netNavUP and netNavDown are causeing the exception.

    My js code is as follows:-

    function netNavDown ()tmp( )

    {

    goID var ="";

    blackberry.ui.dialog.standardAskAsync ("to:" + goID, blackberry.ui.dialog.D_OK, tmp);

    tmp ++;

        if (tmp is appViewArray.network.length)

    {

    goID = "nliEnd";

    }

    on the other

    {

    goID = "NIF" + tmp.toString ()";

    }

    blackberry.focus.setFocus (goID);

    }

    As you can see the standardAskAync should give me some information, but never gets fired. No, I know it's asynchronous if she fell into the code. That's why I removed the call to set the focus. So indeed it would fulfil this function and return control to the html code.

    The error I get in the Simulator is - App error 104 - Eception RuntimeException

    I tried to lose the $index () and replace it with a number directly I can see if that was the problem, but no, I still get exactly the same error. Then there is a problem with X-blackberry-onDown? and onUp than also causes the crash. Note that I use navigation everywhere else without too much problem, but it's the only place where I "force" of a specific focal point, setting the focus is also not a problem I put emphasis in the code when it starts first, and that works. The fixed focus is commented, so it hangs a little on the call of the function as the first line of the function is an alert (of sorts)

    I solved this by sending not anything to the function, but rather when I get to the function to get the item currently developed. not the best solution, but it works.

    var id = blackberry.focus.getFocus ();

  • How can disable the scrolling animation when setFocus

    I'm working now on a screen of IM conversation. When the user send a message, the list of instant messaging on the screen will be updated the I setFocus on the message input field: this occors a problem after OS 6.0 because the list will always be scrolling up and down...

    If I need to replace any method as moveFocus to achieve?

    Try setScrollingInertial (false) on your Manager. If you are using screen, you can try yourScreen.setScrollingInertial (false), but if this does not help, oneOfYourFields.getManager () .setScrollingInertial (false) should (use after having added your fields on the screen).

  • Focus with GridFieldManager problem

    I'm having a problem of development/unfocus.  A label should draw a border of red around him when it gets the focus and a black border when he loses it.  But when I add/remove a label for a GridFieldManager (see below the code and the screenshot), I find that the update will temporarily to the field at (0,0) and 'loses' never the focus - in other words, he draws a red border, but never black.  So, I end up having 2 fields with the red border - something that should never happen!

    I'm under 5.0 SDK on Eclipse.  I reproduced the problem in the simplest possible form: If you import the following code, you'll see for yourself.  Please help me!

    Import net.rim.device.api.ui.XYEdges;
    Import net.rim.device.api.ui.component.LabelField;
    Import net.rim.device.api.ui.container.GridFieldManager;
    Import net.rim.device.api.ui.container.MainScreen;
    Import net.rim.device.api.ui.decor.Border;
    Import net.rim.device.api.ui.decor.BorderFactory;

    / public final class screen extends MyScreen
    {
    private GridFieldManager MDT;
       
    public MyScreen()
    {
    Set the displayed title of the screen
    setTitle ("MyTitle");
    int size = 3;
    GFM = new GridFieldManager (size, size, GridFieldManager.FIELD_HCENTER |) GridFieldManager.FOCUSABLE);
    for (int y = 0; y)< size;="" y++)="">
    for (int x = 0; x)< size;="" x++)="">
    LabelField nf = new LabelField ("H", LabelField.FOCUSABLE) {}
    protected boolean navigationClick (int time, int status) {}
    swap (this);
    this.setFocus ();
    Returns true;
    }

    Protected Sub onFocus (int direction) {}
    this.setBorder (BorderFactory.createSimpleBorder (new XYEdges (1,1,1,1), new XYEdges(0xFF0000,0xFF0000,0xFF0000,0xFF0000), Border.STYLE_DASHED));
    }
                       
    protected void onUnfocus () {}
    this.setBorder (BorderFactory.createSimpleBorder (XYEdges (1,1,1,1))) of new;
    }

    };
    nf.setBorder (BorderFactory.createSimpleBorder (XYEdges (1,1,1,1))) of new;
                   
    GFM. Add (NF);
    }
    }
    Add (GFM);
    }
       
    private void swap (LabelField lf) {}
    GFM. Delete (LF);
    GFM. Add (LF);
    }
    }

    Thus, even if I clicked on the intermediate element, an area of development is established around the item to (0,0)

    Why is this?

    Sorry to get to this post, this late - I could have saved a lot of traffic if I noticed it earlier...

    In any case - onUnfocus has a very strange behavior. In some cases (I don't know which) it is not called at all when the field loses focus. So, rather than using onFocus/onUnfocus pair, use FocusChangeListener. This listener will turn on the eventType and onFocus on FOCUS_GAINED work and the work of onUnfocus on FOCUS_LOST.

    Overall, it will look like this:

    import net.rim.device.api.ui.XYEdges;
    import net.rim.device.api.ui.component.LabelField;
    import net.rim.device.api.ui.container.GridFieldManager;
    import net.rim.device.api.ui.container.MainScreen;
    import net.rim.device.api.ui.decor.Border;
    import net.rim.device.api.ui.decor.BorderFactory;
    
    public final class MyScreen extends MainScreen
    {
        private GridFieldManager gfm;
    
        public MyScreen()
        {
            // Set the displayed title of the screen
            setTitle("MyTitle");
            int size = 3;
            FocusChangeListener fcl = new FocusChangeListener() {
              public void focusChanged(Field field, int eventType) {
                switch (eventType) {
                case FOCUS_GAINED:
                  field.setBorder(BorderFactory.createSimpleBorder(new XYEdges(1,1,1,1), new XYEdges(0xFF0000,0xFF0000,0xFF0000,0xFF0000), Border.STYLE_DASHED), false);
                  break;
                case FOCUS_LOST:
                  field.setBorder(BorderFactory.createSimpleBorder(new XYEdges(1,1,1,1)), false);
                  break;
                case FOCUS_CHANGED:
                  break;
                default:
                  break;
                }
              }
            };
            gfm = new GridFieldManager(size,size,GridFieldManager.FIELD_HCENTER|GridFieldManager.FOCUSABLE);
            for (int y = 0; y < size; y++) {
                for (int x = 0; x < size; x++) {
                    LabelField nf = new LabelField("H", LabelField.FOCUSABLE) {
                        protected boolean navigationClick(int time, int status) {
                            swap(this) ;
                            this.setFocus();
                            return true;
                        }
    
                    };
                    nf.setBorder(BorderFactory.createSimpleBorder(new XYEdges(1,1,1,1)));
                    nf.setFocusListener(fcl);
    
                    gfm.add(nf);
                }
            }
            add(gfm);
        }
    
        private void swap(LabelField lf){
            gfm.delete(lf);
            gfm.add(lf);
        }
    }
    

    You will notice that I have created a FocusChangeListener to listen each LabelField and changed calls setBorder on focus has changed not update in page layout (as does not change the size of the border), which will make it much more effective and does not cause the entire screen redraw

    You can do even better if you setBorder on the ground as it is created, but use the long form - viewable one following first parameter. Define borders forVISUAL_STATE_FOCU andVISUAL_STATE_NORMA at least. Again, take a long look at prototypes withupdateLayou indicator. This way you won't have to worry about changes in development at all - the system will do it for you

  • Horizontal scrolling for the GridField Manager problem

    Hi all

    I have my working in the Application in which I have my display my data using GridField Manager. I used the code in the example given in link by tboatright of the user.

    Now in my application, I used the extension of the screen and it automatically gives the vertical scroll bar if the total height of lines in my GridField Manager is more than BB Simulator screen. In using this I can scroll vertically easily by substituting navigationMovement (int dx, int dy, int, int time status) method...

    Now the problem is, I have 6 columns in my network manager and their width is 80 each. So only 3 columns are displayed on the Simulator screen when the first time grid is displayed but I get no horizontal scroll bar, I m not able to scroll horizontally through my all columns. Now using dominant navigationMovement (dx int, int dy, int, int time status) method (in accordance with its encoding in the above link), I am able to setFocus on the columns by pressing the left/right keys on my keyboard on Simulator of BB, but with this screen doesn't move (scroll) left or right accordingly if I m not able to see column4 column 5, column6, which are placed to the right of the main screen width of BB.

    I hope that my question in the clear for you guys...

    Thanks in advance

    You have set the style for the screen like HORIZONTAL_SCROLLBAR and HORIZONTAL_SCROLL? because the style VERTICAL_SCROLL and VERTICAL_SCROLLBAR will be set by default. We must define explicitly for horizontal scrolling

  • Scrolling lists problem

    Hello!

    I have a list of simple fixed size created with

      and
    • Tags. I can test on my Bold 9700, but on this device, it can not scroll the list. What is the problem?




         


           


                     

                            
      • ....

      •                     
      • ....

      •                     
      • ....

      •                     
      • ....

      •                     
      • ....

      •                     
      • ....

      •                     
      • ....

      •                     
      • ....

      •                     
      • ....

      •                

            


      even I have the same peoblem so what I did is

      added the onUp and onDown

      • ....
      • ....
      • ....
      • ....
      • ....
      • ....
      • ....
      • ....
      • ....

      and in the script, I managed this onUp and onDown to scroll the div

      function scroll(){
      
          var elm = document.getElementById("mainBodyDiv");    var lastFocusId = parseInt(blackberry.focus.getFocus());
      
          switch(blackberry.focus.getDirection()){         case 2 : // up            if(lastFocusId < 1 && lastFocusId > 9) //lastFocusId less than first element and greater than last element                blackberry.focus.setFocus((lastFocusId-1)+"");            elm.scrollTop -= 50; //height of single 
    • element break; case 3 : // down if(lastFocusId > 0 && lastFocusId < 9) blackberry.focus.setFocus((lastFocusId+1)+""); elm.scrollTop += 50; break; }}
    • I recommend you generate javascript dynamically list in a table and give this table as input to the scrolling feature so that even if you want to add elements of the latter or to generate the list based on a response from the server, it will be very useful

  • ListField setListSelection() problem of drawing

    Hi all, I'm new in the development of bb and I will try to create a ListField class to manage ListField and ListFieldCallBack design, but I have a problem with ListField SetSelectedIndex (Position), because ListFieldCallBack does not "drawListRow" (don't shoot list lines) and ListField seems to be empty, it restarts to draw only when users scroll ListField control.
    I don't really know how to resolve or work around this problem...
    I try with RIM Jde 5.0.0 and BB Storm 9550

    Application - start
    Grid VediOrdini = new Grid();
    VediOrdini.Inizialize ("Select CodCli, CodLinea, coding of AgeLinea", Gv.Db, this);
    VediOrdini.AddColumnPerc (0, "CodCli", "L", 40);
    VediOrdini.AddColumnPerc (1, "CodLinea", 30, "C");
    VediOrdini.AddColumnPerc (2, "Coding", 30, "R");
    VediOrdini.Draw ();
    VediOrdini.SetSelectedIndex (350);

    -Draw() class ListField
    MiaLista = new ListField(); Lista oggetto Dichiaro
    MiaLista.setRowHeight (RowHeight); Transamissões is delle lines
    MiaCallBack = new TestListCallback(); Reminder it derivo by manage the list
    MiaLista.setCallback (MiaCallBack); E lo transamissões sulla mia lista
    RowSelected = - 1; Inizializzo he number di riga per poterlo manage poi selezionata e tornare in caso di GetSelectedIdex
    Line r;
    int i = 0;
    {while (DataReader.Next ())}
    r = DataReader.getRow (); Ciclo he mio "DataReader".
    MiaLista.insert (i); Will di volta in volta una riga alla lista
    By mi ogni Riga del datareader i campi della riga in one Salvo ' oggetto line
    Lines MiaRiga = New Rows (Colonna.size (), r);
    Riga.addElement (MiaRiga);

    i ++ ;
    }
    MyVFieldManager VFieldManager = new MyVFieldManager (Manager.VERTICAL_SCROLL, ListWidth, ListHeight);
    VFieldManager.add (MiaLista); Gli bell'attacco E degli articles list
    SC. Add (VFieldManager); Lo will went form

    -SetSelectedIndex (Posizione) class ListField
    MiaLista.setFocus ();
    MiaLista.setSelectedIndex (Posizione);
    Manager manager = MiaLista.getManager ();
    manager.setVerticalScroll (Posizione * RowHeight);
    MiaLista.invalidateRange (Posizione, (Posizione + RowPage));

    Can someone help me please?
    Thanks in advance

    I've seen problems such as too, where the setSelectedIndex must run on the event Thread.

    The best thing to do is some code to be run in this way and use "invokeLater" package.  I actually do sometimes even when I'm on the edge of events, because I want to change to take place later.

    Then put the setSelectedIndex and everything you think you need to do, in one of them:

    UiApplication.getUiApplication () .invokeLater (new Runnable() {}

    public void run() {}

    here

    {

    {);

  • Custom ComboBox problem

    Hello

    I'm doing a custom combobox. I don't want pictures in that text. Inspired by DDImagesButton I coded my Combobox. But am experiencing a few problems with it.

    For the button, I created TextButtonField. Problem that I face this is it shows text only when you click on it once. Otherwise, it shows just background color. Here's the code for TextbuttonField:

    public class TextButtonField extends ButtonField implements FocusChangeListener {
        protected DropdownItem mItem;
        boolean mTextItem;
        int mWidth;
        int mHeight;
        private static final int FOCUS_COLOR_BORDER = Color.RED; //0xFC0000;
        private static final int UNFOCUS_COLOR_BORDER = Color.WHITE;
        private int borderColor = FOCUS_COLOR_BORDER;
        private int color;
        private boolean selected;
    
        public TextButtonField(String text) {
            this(new DropdownItem(null, text), true);
        }
    
        private TextButtonField(DropdownItem item, boolean textItem) {
            super(item.mName, CONSUME_CLICK);
            mItem = item;
            mTextItem = textItem; 
    
            mWidth = (mTextItem ? getFont().getAdvance(mItem.mName) + 6 : 0);
            mHeight = getFont().getAscent() + 6; 
    
            // Save the Width & Height for layout
            mItem.itemWidth = mWidth;
            mItem.itemHeight = mHeight;
    
            setPadding(3, 6, 3, 6);
            setMargin(0, 0, 0, 0);
            this.setBackground(BackgroundFactory.createSolidBackground(Color.RED));
            setBorder(BorderFactory.createSimpleBorder(new XYEdges(0, 0, 0, 0), Border.STYLE_TRANSPARENT));
            setBorder(VISUAL_STATE_ACTIVE, BorderFactory.createSimpleBorder(new XYEdges(0, 0, 0, 0), Border.STYLE_FILLED));
            setFocusListener(this);
        } 
    
        public TextButtonField(String text, int bgColor) {
            this(new DropdownItem(null,text), true);
            this.setBackground(BackgroundFactory.createSolidBackground(bgColor));
        }
    
        protected void paint(Graphics graphics) {
            super.paint(graphics);
        } 
    
        public int getPreferredWidth() {
            return mWidth;
        } 
    
        public int getPreferredHeight() {
            return mHeight;
        } 
    
        protected void layout(int width, int height) {
            setExtent(mWidth, mHeight);
        } 
    
       public void focusChanged(Field field, int eventType) {
            if (eventType == FocusChangeListener.FOCUS_GAINED) {
                borderColor = FOCUS_COLOR_BORDER;
                invalidate();
            }
            if (eventType == FocusChangeListener.FOCUS_LOST) {
                borderColor = UNFOCUS_COLOR_BORDER;
                invalidate();
            }
        }
    
        protected void drawFocus(Graphics g, boolean on) {
            paint(g);
        }
    }
    

    By using this class, I created the ComboBox class such as:

    public class ComboBox extends TextButtonField implements FieldChangeListener {
        DropdownItem[] mItems;
        int mIndex;
        boolean showSelectedText;
        private int maxTextInd =0;
    
        public ComboBox(DropdownItem items[]) {
            super(items[0].mName);
            mItems = items;
            updateIndex(0);
            setChangeListener(this);
        }
    
        public ComboBox(DropdownItem items[], int bgColor) {
            super(items[0].mName, bgColor);
            mItems = items;
            updateIndex(0);
            setChangeListener(this);
        }
    
        protected void paint(Graphics graphics) {
            super.paint(graphics); 
    
            int x = 0;
            int ht =  0;
            x = this.getFont().getAdvance(mItems[maxTextInd].mName) + 5;
    
            int y = 5; 
    
            int y1 = y;
            int y2 = y + 10;
            int x1 = x;
            int x2 = x + 18;
            int[] xPts = new int[] { x1, x2, x1 + 9 };
            int[] yPts = new int[] { y1, y1, y2 };
            graphics.drawFilledPath(xPts, yPts, null, null);
        } 
    
        public void fieldChanged(Field f, int context) {
            getScreen().getUiEngine().pushScreen(new ComboPopUp());
        }
    
        public void updateIndex(int index) {
            mIndex = index;
            mItem = mItems[mIndex];
            invalidate();
        }
    
        public int getSelectedIndex() {
            return mIndex;
        }
        public String getSelectedItem() {
            return mItems[mIndex].mName;
        }
    
        class ComboPopUp extends PopupScreen implements FieldChangeListener {
            public ComboPopUp() {
                super(new VerticalFieldManager(VERTICAL_SCROLL | VERTICAL_SCROLLBAR));
                for (int i = 0; i < mItems.length; i++) {
                    TextButtonField button = new TextButtonField(mItems[i].mName);
                    add(button);
                    button.setChangeListener(this);
                }
                getField(mIndex).setFocus();
            } 
    
            protected boolean keyChar(char key, int status, int time) {
                if (Keypad.KEY_ESCAPE == key) {
                    this.close();
                    return true;
                } else
                    return super.keyChar(key, status, time);
            } 
    
            public void fieldChanged(Field field, int context) {
                updateIndex(getFieldWithFocusIndex());
                this.close();
            }
        }
    }
    

    * Here if the index is changed, I want to see the ot the button of the selected index. I want to say that if I have 2 items in the drop-down list 'Save' & 'Edit', Save is 1 then it will be displayed, if I select "Edit" then change must be considered over the top and not save. This time is seen as st element.

    * In DDImagesButton, next to the button, the triangle is hsown, which indicates a drop down, here how can I show that. In DDImagesButton, I have not found where and what show this triangle.

    * The popup is displayed correctly, but the text is not displayed until the component is selected. This issue will be resolved when TextButtonField problem is solved.

    Although these 2 problems are a little different but as relate to them, I added in the same message.

    Can you help me to solve my problems and help me create the custom drop-down list box. Help is highly appreciated.

    Thank you

    Hi Piotr,

    Consideirng your instructions, I tried to implement and make changes accordingly, but nothing has worked... I knew that both the setBorder is necessary. For ascent, creaed a label with alphabet 'W' and I am for his ascension.

    By developing, I realized the problem and resolved completely. In fact, I've been putting the text of the TextButtonField in super(), I removed that and displays text in object. It also helped me view the drop-down arrow that was not coming. I changed the following code and little bit here & there, and things were as expected.

    private TextButtonField(DropdownItem item, boolean textItem) {
            super(CONSUME_CLICK);
            ..........
     }
    
        protected void paint(Graphics graphics) {
            super.paint(graphics);
            graphics.setColor(Color.WHITE);
            graphics.setFont(textFont);
            graphics.drawText(mItem.mName, XPad, 1);
        }
    

    The drop down menu is not visible completely because of the size of the layout. Changed the width of TextButtonField in ComboBox object after showing the arrow that is:

    totWidth = x 2;

    and layout() TextButtonField:

    Protected Sub layout (int width, int height) {}
    setExtent (Math.max (mWidth, totWidth), mHeight);
    }

    That's all, and my work is done. Above code is added with explanation so can serve to someone else like me.

    Thank you

Maybe you are looking for

  • Iphone6 film moving around images

    6 - Photo App - IPhone Camera Roll - when you take a picture, it will appear in the page "Camera Roll" of the app - my question, is possible to move the image in this app? -in other words from one position to another - thank you.

  • HP Mini 210-2002sa laptop: System Recovery

    Product name: HP Mini 210-2002sa laptop computer model #: XD396EA OS: Windows 7 starter edition   Should I for Microsoft Windows 7 starter product key to perform a system recovery? If Yes, where can I get it? The only thing I have is the OEM product

  • Smartband swr10 play pause winamp

    I can't get my game smartband and interrupting my winamp on my xperia z2He successfully blew up and back between songs, but the play/pause does not work. He used to work on the player, but I uninstalled because I want to use winamp instead and before

  • Must I "upgrade" from XP to Windows 7?

    I ran the upgrade wiz and he said: I have my computer can handle Windows 7, although a lot of my programs and devices will not be usable... I have a Thinkpad with 4 GB and a Centrino 2 quick... What do you think? I must: (1) just keep XP (2) upgradin

  • Typekit fonts do not display in iPad app DPS (created by Indesign) in Web content (leading edge)

    I think I tried every permutation to make this work, but probably miss me something.I'm creating a single application iPad DPS with InDesign, and I use a Typekit font throughout.  So far so good.I created a project to animate Dashboard using the same