RichTextField focusable

How to make a RichTextField focusable, but that can be selected or not editable?

What I want is a field that has the text formatting of a RichTextField options but behaves like a LabelField set to Focusable.

I want it all to be highlighted when it gets the focus.

Someone at - it suggestions?

Try with this:

RichTextField entry = new RichTextField(combined, offset, attribute, fonts, Field.FOCUSABLE | Field.READONLY )        {            XYRect focusRect;            protected void onFocus(int direction)             {                if ( focusRect == null )                 {                    focusRect = this.getExtent();                }                super.onFocus(direction);            }            public boolean isSelectable()             {                return false;            }            protected void drawFocus(Graphics g, boolean on)             {                if ( focusRect != null )                 {                    super.drawHighlightRegion(g, Field.HIGHLIGHT_FOCUS, on, 0, 0, focusRect.width, focusRect.height);                                    }                 else                 {                    super.drawFocus(g, on);                                    }            }            public void getFocusRect(XYRect rect)             {                if ( focusRect == null )                 {                    super.getFocusRect(rect);                }                else                {                    rect.x = 0;                    rect.y = 0;                    rect.width = focusRect.width;                    rect.height = focusRect.height;                }                             }                        public int moveFocus(int amount, int status, int time)             {                return amount;            }

        };

Reference link:

http://supportforums.BlackBerry.com/Rim/Board/message?board.ID=java_dev&message.ID=37567

Concerning

Bika

Tags: BlackBerry Developers

Similar Questions

  • How to activate a RichTextfield to receive Focus

    I'm doing a RichTextField can receive focus.

    I am against the Version 4.3 programming. The API documentation specifies that to make a RichTextField unable to receive focus, we should pass to the constructor the bit style NON_FOCUSABLE, implying that, by default, it is able to receive the focus.

    But when I scroll down using the arrow key down in the Simulator on a RichTextFields screen, I always null when calling "getLeafFieldWithFocus" in the fields Manager. It works when I can replace the EditFields RichTextFields.

    When I try to spend the FOCUSABLE style bit to the constructor, the Simulator throws an exception in the constructor call.

    Is there a way of 4.3 to a Textfield read-only able to receive the focus?

    Passing RichTextField.FOCUSABLE when building a RichTextField works very well for me in JDE 4.3.0

  • Bluetooth data + screen

    Dear BB community,

    I'm playing with the BluetoothDemo code example provided with JDE4.5.

    I managed to connect the BB (8310) to a PC and send/receive characters.

    My problem is that once the characters fill to the top of the screen of BB I can't scroll down to see the next

    batch processing. Anyone have any suggestions on how I could make the scrolling of the screen that it has received new data.

    Thanks in advance.

    David

    Proj files:

    AppScreen.java

    SSPScreen.java

    Bluetoothdemo.Java

    Figured it out!

    Changed the field of incoming stream of RichTextField.NON_FOCUSABLE to RichTextField.FOCUSABLE txt

  • Editable RichTextField does not allow edit

    If a RichTextField can be changed?  I can't get this to work.  Here is a code:

    _rtf = new RichTextField(RichTextField.EDITABLE);
    
    _rtf.SetText("Something I will change);
    

    However, when I run the present on the device, I can focus on the field, but cannot change it (typing does nothing).  Any ideas?  If a richtextfield can be changed (I guess that one b/c it has this property)?  Is there another type, I should use?

    Thank you

    Scott

    RichTextField is read-only. An EditField should fit if you want to change.

  • RichTextField unselectable

    Hi, did anyone know how I can do a unselectable RichTextField?  I want to stop the user to be able to highlight text and copy and paste it.  I tried making it non-Focus, but then I have a problem with the scrolling if the content of the field is larger than the screen.

    Any suggestions?

    Hi all, where everyone is looking for a solution to this, I found it.

    RichTextField textField = new RichTextField(){
        public boolean isSelectable(){
            return false;
        }
    };
    

    I assumed that the API uses the method isSelectable() internally to decide whether or not to allowing to select the mode.  So by too much riding it and always returns false, it is not possible select the text by using any method (menu item or keyboard shortcuts).

  • Storm Long RichTextField

    Hello comrades!

    I had a situation associated with RichTextField that contains a long text on the device of the storm.

    The problem is: I am able to scroll the text, but I can't move the focus to a CustomBitmapField, are complemented by the text Manager, until I reach the end of the text.

    The button appears on the screen, but when the user clicks the text above simply scroll down.

    All entries? Thanks in advance.

    public class Screen extends FullScreen implements FieldChangeListener {
    
        private Bitmap startQuizNormal, startQuizFocused, bitmapBackground;
        private CustomBitmapField startQuiz;
        private BitmapField introImage;
    
        private VerticalFieldManager introTextouterManager;
    
        private int startQuizHeight, introTextHeight;
    
        private String text;
    
        private int width;
        private int height;
    
        public IntroScreen() {
            super(DEFAULT_CLOSE | USE_ALL_HEIGHT | USE_ALL_WIDTH | Screen.NO_VERTICAL_SCROLL);
    
            this.width = Display.getWidth();
            this.height = Display.getHeight();
            this.renderScreen();
        }
    
        private void renderScreen() {
    
            RichTextField introduction;
    
            Font fonts[] = new Font[2];
            int[] offset = new int[7];
            byte[] attribute = new byte[6];
    
            fonts[0] = Font.getDefault().derive(Font.PLAIN, 18, Ui.UNITS_px);
            fonts[1] = Font.getDefault().derive(Font.BOLD, 19, Ui.UNITS_px);
    
            text = "long text...";
    
            offset[0] = 0;
            attribute[0] = 1;
    
            offset[1] = 15;
            attribute[1] = 0;
    
            offset[2] = 1377;
            attribute[2] = 1;
    
            offset[3] = 1396;
            attribute[3] = 0;
    
            offset[4] = 1652;
            attribute[4] = 1;
    
            offset[5] = 1664;
            attribute[5] = 0;
    
            offset[6] = text.length();
    
            if (this.width == 360) {
                this.bitmapBackground = Bitmap.getBitmapResource("background360x480.jpg");
            } else {
                this.bitmapBackground = Bitmap.getBitmapResource("background480x360.jpg");
            }
    
            startQuizNormal = Bitmap.getBitmapResource("startquiznormal.png");
            startQuizFocused = Bitmap.getBitmapResource("startquizfocused.png");
    
            startQuizHeight = startQuizNormal.getHeight();
    
            introTextHeight = this.height - (startQuizHeight + 16);
    
            introduction = new RichTextField(text, offset, attribute, fonts, RichTextField.USE_TEXT_WIDTH | RichTextField.READONLY );
    
            startQuiz = new CustomBitmapField(startQuizFocused, startQuizNormal, FIELD_HCENTER | FIELD_VCENTER);
            startQuiz.setChangeListener(this);
    
            introTextouterManager = new VerticalFieldManager(FIELD_HCENTER | VERTICAL_SCROLL | NON_FOCUSABLE) {
                protected void sublayout(int maxWidth, int maxHeight) {
                    super.sublayout(width - 40, introTextHeight);
                    super.setExtent(width - 40, introTextHeight);
                }
            };
    
            introTextouterManager.add(introduction);        
    
            add(introTextouterManager);
    
            add(startQuiz);
    
        }
    
        protected void paintBackground(Graphics g) {
            g.drawBitmap(0, 0, this.width, this.height, this.bitmapBackground, 0, 0);
        }
    
        public void fieldChanged(Field field, int context) {
            if (context == 0)
                UiApplication.getUiApplication().pushScreen(new MenuScreen());
        }
    
        protected void sublayout(int width, int height) {
            if (this.width != width) {
                this.width = width;
                this.height = height;
                UiApplication.getUiApplication().invokeLater(new Runnable(){
                    public void run() {
                        renderScreen();
                    }
                });
            }
            super.sublayout(width, height);
        }
    }
    

    Everyday learning!

    A big thank you Vignesh J. for the idea.

    So, I just replace the touchEvent at the level of the screen, but rather to return false when the target button was not clicked on return "super.touchEvent (event)". And then it works! Not sure if this solution is the best.

    In addition, as suggested, we composed a ClickListener instead of implements FieldChangeListener.

    public interface ClickListener {
       public boolean onNavigationBallClicked(Field f,int status, int time);
    }
    
    public class IntroScreen extends FullScreen implements ClickListener {
    
    ...
    
      startQuiz = new CustomBitmapField(startQuizFocused, startQuizNormal,
                    FIELD_HCENTER | FIELD_VCENTER);
      startQuiz.setClickListener(this);
    
    ...
    
    protected boolean touchEvent(TouchEvent event){
        int x = event.getX(1);
        int y = event.getY(1);
        int index = getFieldAtLocation(x, y);
        try {
            Field f = getField(index);
            if (f instanceof CustomBitmapField) {
                switch(event.getEvent()){
                case TouchEvent.DOWN:
                    f.setFocus();
                    invalidate();
                    return true;
                case TouchEvent.UNCLICK:
                    return ((CustomBitmapField)f).getClickListener().onNavigationBallClicked(this, 0, 0);
                }
            }
        } catch (Exception e) {
            return super.touchEvent(event);
        }
        return super.touchEvent(event);
      }
    
    }
    
  • RichTextField truncation of text or ellipsis

    Hi I'm new to dev Java of BB and I'm trying to truncate the text to a non-focusable RichTextField. Is this possible?

    I tried without success to the following:

    ...RichTextField _myRTF = new RichTextField(my_text, off, attrs, fonts, (DrawStyle.ELLIPSIS |
      RichTextField.FIELD_LEFT |
      RichTextField.NON_FOCUSABLE |
      RichTextField.NO_NEWLINE)) { ... };...
    

    I also tried to use Labelfield.ELLIPSIS with no luck. This works for LabelField, but I use RichTextField because I'm using different font styles.

    I ended up using LabelField with LabelField.ELLIPSIS, overiding the paint method and setting the police in there.

  • Can not get the focus within a HorizontalFieldManager

    Hello

    I have several HFM in an optimization of resources.

    Each HFM contains a RichTextField. I want to do is make a button appear near the RichTextField in the HFM every time a line is "concentrated" (i.e. when the cursor is on a single line) and make them disappear when I change line (to make it appear on the ranks.

    What I do is the following:

    HorizontalFieldManager row = new HorizontalFieldManager(HorizontalFieldManager.USE_ALL_WIDTH) {                               protected void onUnfocus() {                    this.deleteRange(1, 1);                }                                protected void onFocus(int direction) {                    ButtonField getDetailsButton = new ButtonField("See details", Field.FOCUSABLE);                    this.add(getDetailsButton);                };                            RichTextField cNameLabel = new RichTextField("test", Field.FOCUSABLE | Field.FIELD_VCENTER | RichTextField.USE_TEXT_WIDTH);                        row.add(cNameLabel);            this.vfm.add(row);
    

    I get the Visual effect that I wanted (the button appears on the line, when I focus it and dispear when I leave) but the problem is that I can't get the focus on my button or textfield object. There is no cursor. And if I try to do it by programming (mybutton.setFocus () in the OnFocus() function) I get a nullpointerexception.

    No idea what's wrong? Thank you

    As far as I know that you can't focus on an area that is managed by the field that is active. An easier way to do this can be with a nullfield active within your HFM and use instead.

  • How UnFocus the RichTextField

    In blackberry, I can use the wheel to control the update in the application.

    Recently, I create an application that has a RichTextField. When I use the wheel to control the update, it will define the RichTextField in short. But I want to unplugged the cursor focus in this RichTextField. What is a way to do it?

    I think that this thread is discussing the same question you ask yourself:

    How to make a NON_FOCUSABLE field at run time

    http://supportforums.BlackBerry.com/Rim/Board/message?board.ID=java_dev&thread.ID=27304

  • Part of labelfield Focus

    Hi all

    I have a labelfield with the text of the "he is an example of a text on which you can access this html page by clicking on www.google.com and send me an email [email protected] please click on this."

    I would ony www.google.com and [email protected] to focus and navigate to browserfield or email respectively.

    Anyone tried and if so can you let me know how you did it.

    If there is a code, it would be a great help.

    Thanks in advance.

    In the hope of sone of you hear.

    Krishnan.

    Thank you Simon and Govind.

    And sorry for this late reply.

    Simon I tried your method, but I was not able to highlight the required text.

    I tried your approach, it wasn't properly kaleidoscope of Govind for example when text on the second label has become huge it allows to move immediately to the bottom and he was pulling to the right.

    Finally, I decided to go with a static web page with two links that solved my problem and works fine.

    But really thanks for sharing these detials.

    And if you find a way to solve via a richtextfield or a labelfield, please let me know.

    Concerning

    Krishnan.

  • Scroll the VerticalFieldManger to see the full content of the message without losing focus on the AutoTextEditField

    I create the application such as chat window.

    I used VerticalFieldManager, AutoTextEditField and RichTextField.

    AutoTextEditField - tap the message.

    RichTextField - add the chat messages

    RichTextField is add in VerticalFieldManager.

    How to scroll the VerticalFieldManger to see the full content of the message without losing focus on the AutoTextEditField.

    Override navigationmovement. This is example how im using it.

    protected boolean navigationMovement(int dx, int dy, int status, int time)
     {
      if (dy==1)
        {
    
      int newscroll = mains.getVerticalScroll();
      int pageheigh = mains.getHeight();
        mains.setVerticalScroll(newscroll+50);
        invalidate();
      return true;  }
    
    return super.navigationMovement(dx, dy, status, time);}
    

    50. This is the step. This is very good work for me (but must create if newscroll <0 and="" if="" newscroll="">the field of cat yourmanager)

    area = VerticalFieldManager()

    Hope this makes you help.

    Best regards, Peter.

  • Field focuses do not

    Hello

    For me RichTextField get does not it comes by default white background and black text. So please help me to fix the sentence. Why he isn't getting focused with the specified color.

    Here is the code I use.

     Phone = new ExRichTextField(sphone){
                int _bgColor;
                int _txtcolor;
                    public void onFocus(int direction) {
                  _bgColor = Color.ORANGE;
                  _txtcolor=Color.BLACK;
                      invalidate();
                      super.onFocus(direction);
                       Phone.setPhoneNumber(sphone);
                        Phonenumber=this.getPhoneNumber();
                         s.addMenuItem(new MenuItem("call",1,1) {
    
       public void run() {
        makeCall(Phonenumber);
    
       }
      });
    
           }
    
           public void onUnfocus() {
                  super.onUnfocus();
                 _bgColor = Color.ALICEBLUE;
                 _txtcolor=Color.BLACK;
                    invalidate();
                    s.removeAllMenuItems();
           }
    
                               public void paint(Graphics g) {
                                   g.setColor(_bgColor);
                                   g.setColor(_txtcolor);
                                    super.paint(g);
                            }
                    };
    
    class ExRichTextField extends RichTextField {
    
                public ExRichTextField(String text) {
                    super(text,Field.FOCUSABLE);
    
            }
    
    }
    

    I have trouble reading your code, because you seem to have a combination of substitutions that I'm not sure.  Here is an example which I think is what you want in terms of development.  You can find a way add/remove the item from the menu in this treatment.

    class ExRichTextField extends RichTextField {
        int _bgColor = Color.ALICEBLUE; // initially unfocused
        int _txtcolor = Color.BLACK;
    
        public ExRichTextField(String text) {
            super(text,Field.FOCUSABLE);
        }
    
        public void onFocus(int direction) {
            super.onFocus(direction);
            _bgColor = Color.ORANGE;
            _txtcolor=Color.BLACK;
            invalidate();
        }
    
        public void onUnfocus() {
            super.onUnfocus();
            _bgColor = Color.ALICEBLUE;
            _txtcolor=Color.BLACK;
            invalidate();
        }
    
         public void paint(Graphics g) {
             g.setBackgroundColor(_bgColor);
             g.clear();
             g.setColor(_txtcolor);
             super.paint(g);
         }
    
    }
    
  • TextField Focusable!

    Hi, I want some show a text on the screen that should be focusable and become blue when get worn so that I can perform an action by clicking on it. What should I use. I tried richtextfield with focus like the style, but his does not work...

    Please suggest.

    create a labelfield with style FOCUSABLE, it must provide you with the desired behavior.

  • iPhone 7 - camera can not focus/blur distant objects

    Recently got my iPhone 7 two weeks ago, when he was released. My camera was working fine but for the last two days, when I try to focus on a person/object far away, it remains unclear. It is not just sharpen or focus on the person/object. It's only focus on something that is very close to the camera. You're not sure if it is a new problem...? Someone knows how to fix this? Thank you.

    Hey jdcn204,

    Thank you for using communities Support from Apple. I can see from your post that you are having problems with your iPhone 7 camera being fuzzy or blurry when you try to take pictures. I understand how it is important for the camera to work as expected and want to do all that we can to remedy to this. I have included a link below which has a section focused on the ways to solve this class under your photos are blurry or out of focus:

    Get help with the camera on your iPhone, iPad or iPod touch

    Let us know if that helps.

    See you soon.

  • iOS 10 Photo Focus Glitch

    Hey.

    For several months now with no problems at 6s. A few days ago, I updated to iOS 10. Today, I used camera first time after the update and discovered that, after that I started the default camera app, developed hanged. I mean that the application itself is very good. Can I change the mode. Once I'm on the video, it's still okay. I restart, put the phone on the table and a few hours after app restart: same thing, the update crashes. As if the camera hangs on start trying to concentrate in the blurred image. If I move the camera, photo exchange a little, but still, not not focusing. And the strange thing is that when I go to the front camera, it hangs along the main camera as well. After passing mode, it's still okay.

    The main issue which is a bug in the iOS 10? I can't believe out of material can appear like that out of the blue and only affect the two devices in a mode...

    See the instructions in this link, under the heading "your photos are blurry or fuzzy":

    Please come back and we all know if this was helpful.  Good luck!

Maybe you are looking for

  • The 12 c Financial Calculator manual

    Owner's manual and troubleshooting guide is available as a PDF anywhere on the HP Web site?  I have not been able to locate.

  • laptop escalates during

    my hp Pavilion 15 notebook pc is getting more heated while using it even for five minutes and he gets are cooled in mode 'sleep' when it is completely recharged using 1 and half an hour, that the battery runs out. Please tell me the steps yo control

  • MX 920 does not print

    Just bought a new MX920 and implemented following the indications of the clos.  It will not automatically adjust head alighment.  In fact, I can't print anything at all.  No matter what I try, it feeds a blank page. I think I missed somehing in Setup

  • Upgrade MSDS

    Hi all Intend to upgrade the TMS of 14.5 to 15.3. Can put us directly to level? We also intend to upgrade from 8.6 to 8, 8 VCS - can upgrade us directly? Dev

  • I want to upgrade to Windows 7 Starter 64 Bit of Windows XP Professional 32-bit, is it feasible?

    If the Starter does not come with 64-bit, then Home Basic or Premium. I want to just update and not start from scratch. Thanks for your quick response.