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).

Tags: BlackBerry Developers

Similar Questions

  • Unable to choose 'clear history' - it is greyed out and unselectable

    I can't select 'clear history' - it is greyed out and unselectable on my laptop. Only, it happens on my laptop, but shows my story for many months in the past and includes the history both of my desktops, which is supposed to be cleared frequently. Sync is enabled on all devices, and history does not appear on desktop computers. I am able to clear the history on desktop browsers, but not the laptop. Computer laptop operating system: Windows 7 Home Premium I also have IE, Chrome, Safari installed.

    Make sure that you are not Firefox running in permanent private browsing mode (don't remember history).

    • Tools > Options > privacy > Firefox will be: "use the custom settings for history".
    • : Uncheck the [] "always use the private browsing mode.

    You can check for problems with the database places.sqlite file in the Firefox profile folder.

  • Lost the power meter of my office - and it is therefore more 'selectable' inside the 'Settings' box of Notifications. Its information line shows currently in gray (unselectable) text instead of the text in black (of your choice).

    I lost the power meter of my office - this little icon that shows when your laptop is plugged in the current House, and where your battery level is when you're not connected to the power of the House

    The problem I found is that it does not appear in mode 'selection' in the 'Settings' box of Notifications.
    Its information line currently shows the text in gray (unselectable) color rather than black (selectable).

    For unknown reasons, the tutorial of vistax64 does not help, so I don't see why not, there is another way...

    Do a system restore. Choose the date where all the icons in the taskbar were present and functional as your restore point.

    Start button > Search box, type system restore > press the Enter key > uac prompt > click on choose a different restore point > next > select dates as your restore point, until the click > next > finish
    To sit and wait. The machine restarts when it's done.

    For the benefits of others looking for answers, please mark as answer suggestion if it solves your problem.

  • Right-aligned a RichTextField?

    I can't seem to get an RTF to right-aligned.

     int[] offsets = { 0, 12, subHeadStr1.length() };
     byte[] attributes = { 0, 1 };
     RichTextField line1 = new RichTextField(subHeadStr1, offsets, attributes, fonts, RichTextField.NON_FOCUSABLE | RichTextField.FIELD_RIGHT);
    
     LabelField line2 = new LabelField(subHeadStr2, Field.NON_FOCUSABLE | Field.FIELD_RIGHT);
     line2.setFont(fonts[0]);
    
     VerticalFieldManager vfmSubHead = new VerticalFieldManager(VerticalFieldManager.USE_ALL_WIDTH | Field.NON_FOCUSABLE);
     vfmSubHead.add(line1);
     vfmSubHead.add(line2);
    

    The 'line 2' LabelField gets justified right very well, but not the RTF.

    Any suggestions?

    Please note that I have not tested myself so maybe it's just a herring-saur, but looking at the documentation for RichTextField there are a number of constant static defined, which is TEXT_ALIGN_RIGHT. Hopefully this by using instead of FIELD_RIGHT?

    Also, sometimes you can use the DrawStyle constants. So if TEXT_ALIGN_RIGHT does not work, try DrawStyle.RIGHT

    Let me know how it goes.

    See you soon,.

    Neil.

  • 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.

  • How to align RichTextField Center?

    Hey all,.

    Been picking at it for some time, using solutions found on many forums. Unable to do things. I have this simple on screen in my application, and I want just all the lines of the text to be centered on the screen horizontally and vertically too if it works. What I'm doing wrong here?

    package com.rim.samples.device.helloworlddemo;
    
    import net.rim.device.api.system.Display;
    import net.rim.device.api.ui.DrawStyle;
    import net.rim.device.api.ui.Field;
    import net.rim.device.api.ui.Manager;
    import net.rim.device.api.ui.component.RichTextField;
    import net.rim.device.api.ui.container.MainScreen;
    import net.rim.device.api.ui.container.VerticalFieldManager;
    
    public class AboutScreen extends MainScreen {
    
        /**
         *
         */
        public AboutScreen() {
            super(Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR);
    
            VerticalFieldManager vfm = new VerticalFieldManager(USE_ALL_WIDTH | FIELD_HCENTER){
                protected void sublayout(int maxWidth, int maxHeight) { 
    
                    super.sublayout(Display.getWidth(),Display.getHeight());
                    setExtent(Display.getWidth(),Display.getHeight());
    
                } 
    
            };
            vfm.add(new RichTextField("Lead Developer - Xxxx Xxxxxxx", Field.NON_FOCUSABLE |            Field.FIELD_HCENTER));
            vfm.add(new RichTextField("For Support - [email protected]", Field.NON_FOCUSABLE |     Field.FIELD_HCENTER));
            vfm.add(new RichTextField("Follow us on Twitter - @xxxxxxxxxx", Field.NON_FOCUSABLE |   Field.FIELD_HCENTER));
            vfm.add(new RichTextField("Version - 1.0.0", Field.NON_FOCUSABLE | Field.FIELD_HCENTER));
            add(vfm);
    
        }
    
    }
    

    Thank you

    Theodore M.

    K so I finally solved easily using the following property in each object - RichTextField

    RichTextField.TEXT_ALIGN_HCENTER

    And that solved everything.

  • 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);
      }
    
    }
    
  • How to get RichTextField to wrap

    Good afternoon fellow developers:

    I was wondering if someone can help me with my problem. I try to get the text to my RichTextField to wrap when I place it in a verticalManager. Basically, if I have:

    Super (NO_VERTICAL_SCROLL);

    lblUserText

    = new RichTextField ("Please select one of the following options below :"); ")

    VerticalFieldManager = vor

    new VerticalFieldManager()

    VFM. Add (lblUserText)

    Add (VFM);

    The text in the RichTextField wraps to the next line very well. But if I do the following:

    Super

    (NO_VERTICAL_SCROLL);

    lblUserText

    = new RichTextField ("Please select one of the following options below :"); ")

    VerticalFieldManager = vor

    New

    VerticalFieldManager()

    {

    protected void paint (Graphics graphics)

    {

    graphics.setBackgroundColor (0xE8E691);

    Graphics.Clear;

    graphics.setColor (0x000000);

    graphics.drawText (lblUserText.getText (), 0,0);

    }

    };

    The text didn't get dressed. It turns off the cut horizontally the "below:" text. Even if I say:

    Super (NO_VERTICAL_SCROLL |) NO_HORIZONTAL_SCROLL);

    It does not work. What I am doing wrong?

    Nothing.

    If you want to support the RichTextField painting yourself, you must implement the package yourself.  drawText painted a line (and a single line).  So you find where the break lines, paint the text on a single line, down the 'y' and paint the next line by the following (and so on).

  • 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.

  • RichTextField setText lower other components?

    I searched this forum a bit.  If I found the correct messages, it seems that I need to use a vertical Manager, but most of the posts I found related to vertical managers were to add scrolling.  It's different.

    I have a screen that has the following in the following order:

    LabelField

    SeparatorField

    RichTextField

    SeparatorField

    ButtonField

    When you click ButtonField, a large amount of data is sent to the RichTextField.setText method.  Instead of SeparatorField and ButtonField which are below the RichTextField moving downwards so that the data can be displayed correctly, it displays all the data but it moving my components above off the screen (at the top).

    Is a manager of vertical, do I have to use to make the SeparatorField and the ButtonField which are below the RichTextField down?

    Look at getVerticalScroll and setVerticalScroll Manager.

    Select the field before doing this.

    Note that in my experience it will not be respected if the field in short could be hidden.

  • Problem with RichTextField on the storm

    In two of my apps, I have a screen that is nothing more than display, image and a RichTextField. I have received a complaint that scrolling cannot be done on the RichTextField, that contains several lines of information. However, in the Simulator, it seems that with a right click and drag, scrolling can be accomplished.

    The user uses os 4.7.0.148.

    Can anyone provide some ideas?

    Kind regards

    Scott

    The application is compiled under JDE 4.7?

    If no, the scrolling is problematic in compatibility mode - this is actually backwards and extremely counterintuitive.

  • 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

  • different color different RichTextField.

    I have the values in the array of strings that size is about 100.

    I want to show this array of strings through RichTextField.

    But I want to show the values is to print in different color.

    Hi nitin,

    Here I m posting for the custom field color code use this field to display different colors.

    public class ColoredLabelField extends RichTextField {
    
        private int textColor;
    
        public ColoredLabelField(String text, int textColor, long style) {
            super(text, style);
            this.textColor = textColor;
        }
    
        public void setTextColor(int color) {
            this.textColor = color;
        }
    
        protected void paint(Graphics graphics) {
            graphics.setColor(textColor);
            super.paint(graphics);
        }
    
    }
    

    Thank you.

  • 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

  • Add ellipses to a multiline RichTextField

    Hi, this is the code of my custom text field Multiline Rich

    As you can see it is very easy to display several lines.

    The problem is that I want to add more features

    Firstly, as a parameter I sent you of the lines, the witch is the maximum amount of the lines I want.

    If the text is too short, I want that number to decrease. Now the text field happens to a lot of height.

    Secondly, the text is too long to be requested amounting to line, at the end of the text, there must be an ellipsis.

    Any ideas?

    public class CustomMultiLineTextField extends RichTextField {
    
        private int lines;
    
        public CustomMultiLineTextField(String text, int lines, long style) {
            super(style);
            this.lines = lines;
            this.setText(text);
        }
    
        protected void layout(int width, int height) {
            super.layout(width, height);
            setExtent(getWidth(), getFont().getHeight() * lines);
        }
    }
    

    The closest thing I found was something like that

    http://www.logresource.com/question/2187245/ShowAll/#additionalAnswersMarker

    And thi

    http://supportforums.BlackBerry.com/T5/Tablet-OS-SDK-for-Adobe-Air/how-to-display-multi-line-text-in...

    Thank you

    Using the first link came with it, not the best solution, but it'll do.

    If you have another idea that I'll want to see.

       void wrapString(String inputString, int width, Font font) {
            line1 = "";
            line2 = "";
            line3 = "";
    
            if (font.getAdvance(inputString) <= width) {
                line1 = inputString;
            } else {
                int charsInLine1 = countCharsInLine(inputString, 0, inputString.length() - 1, width, font);
                int lineBreak1 = inputString.lastIndexOf(' ', charsInLine1);
                if (lineBreak1 == -1) {
                    lineBreak1 = charsInLine1;
                }
    
                line1 = inputString.substring(0, lineBreak1);
                line2 = inputString.substring(lineBreak1 + 1, inputString.length());
    
                if (font.getAdvance(line2) > width) {
                    int charsInLine2 = countCharsInLine(line2, 0,   line2.length() - 1, width, font);
                    int lineBreak2 = line2.lastIndexOf(' ', charsInLine1);
                    if (lineBreak2 == -1) {
                        lineBreak2 = charsInLine2;
                    }
    
                    line3 = line2.substring(lineBreak2 + 1, line2.length());
                    line2 = line2.substring(0, lineBreak2);
    
                    if (font.getAdvance(line3) > width) {
                        int charsInLine3 = countCharsInLine(line3, 0, line3.length() - 1,   width - font.getAdvance("..."), font);
                        line3 = line3.substring(0, charsInLine3) + "...";
                    }
                }
            }
    
            System.out.println("line1: " + line1);
            System.out.println("line2: " + line2);
            System.out.println("line3: " + line3);
        }
    
        int countCharsInLine(String str, int min, int max, int width, Font font) {
            if (min >= max)
                return max;
    
            int guess = min + (max - min) / 2;
            int advance = font.getAdvance(str, 0, guess);
    
            if (advance < width)
                return countCharsInLine(str, guess + 1, max, width, font);
            else if (advance > width)
                return countCharsInLine(str, min, guess - 1, width, font);
            else
                return guess;
        }
    

Maybe you are looking for