ToolTip for the button

Nice day

I'm new to the blackberry development. I created a bitmapbuttonfield using the examples of the advanced user interface. There is a button with an image. I want to display a ToolTip for the button when the button receives the focus. Can someone please help

Thanks in advance

Hello

Use this code:

package mypackage;

import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.component.Dialog;

public final class MyScreen extends TooltipScreen
{

    ButtonField btn1,btn2,btn3;
    public MyScreen() {

        btn1=new ButtonField();
        btn1.setChangeListener(new FieldChangeListener() {
            public void fieldChanged(Field field, int context) {
                Dialog.alert("Button 1 Click");
            }
        });
        btn2=new ButtonField();
        btn2.setChangeListener(new FieldChangeListener() {
            public void fieldChanged(Field field, int context) {
                Dialog.alert("Button 2 Click");
            }
        });

        btn3=new ButtonField();
        btn3.setChangeListener(new FieldChangeListener() {
            public void fieldChanged(Field field, int context) {
                Dialog.alert("Button 3 Click");
            }
        });
        add(btn1, "Button 1");
        add(btn2, "Button 2");
        add(btn3, "Button 3");

    }

}
package mypackage;

import java.util.Timer;
import java.util.TimerTask;
import java.util.Vector;

import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.XYRect;
import net.rim.device.api.ui.container.MainScreen;

public class TooltipScreen extends MainScreen {

    TooltipScreen screen = this;
    boolean doRedraw = false;//prevent infinte redrawing
    Vector tooltips = new Vector();//vector to hold tooltip strings
    private Timer tooltipTimer = new Timer();
    private TimerTask tooltipTask;
    boolean alive = false;//is the tooltip alive? used to pop it after our timeout
    int count = 0;//used to calculate time tooltip is displayed
    //tooltip popup colours:
    int backgroundColour = 0xeeeeee;
    int borderColour = 0xaaaaaa;
    int fontColour = 0x666666;
    //the tooltip:
    String tooltip;
    int tooltipWidth;
    int yCoord;
    int xCoord;
    //region parameters:
    XYRect contentArea;
    int contentBottom;
    int contentRight;

    public TooltipScreen() {
        super();

        //when timeout reaches 100ms*20 ie. 2seconds set alive to false and redraw screen:
        tooltipTask = new TimerTask() {

            public void run() {
                if (alive) {
                    count++;
                    if (count == 20) {
                        alive = false;
                        invalidate();
                    }
                }
            }
        };

        tooltipTimer.scheduleAtFixedRate(tooltipTask, 100, 100);

    }

    //override add method adds an empty string to tooltip vector:
    public void add(Field field) {
        tooltips.addElement("");
        super.add(field);
    }

    //custom add method for fields with tooltip: add(myField, "myTooltip");
    public void add(Field field, String tooltip) {
        super.add(field);
        tooltips.addElement(tooltip);
    }

    public void setColours(int backgroundColour, int borderColour, int fontColour) {
        this.backgroundColour = backgroundColour;
        this.borderColour = borderColour;
        this.fontColour = fontColour;
    }

    //reset everything when user changes focus,
    //possibly needs logic to check field has actually changed (for listfields, objectchoicefields etc etc)
    protected boolean navigationMovement(int dx, int dy, int status, int time) {
        count = 0;
        alive = true;
        doRedraw = true;
        return super.navigationMovement(dx, dy, status, time);
    }

    protected void paint(Graphics graphics) {
        super.paint(graphics);
        if (alive) {
            Field focusField = getFieldWithFocus();
            tooltip = (String) tooltips.elementAt(screen.getFieldWithFocusIndex());

            //don't do anything outside the norm unless this field has a tooltip:
            if (!tooltip.equals("")) {
                //get the field content region, this may fall inside the field actual region/coordinates:
                contentArea = focusField.getContentRect();
                contentBottom = contentArea.y + contentArea.height;
                contentRight = contentArea.x + contentArea.width;

                //+4 to accomodate 2 pixel padding on either side:
                tooltipWidth = graphics.getFont().getAdvance(tooltip) + 4;

                yCoord = contentBottom - focusField.getManager().getVerticalScroll();
                //check the tooltip is being drawn fully inside the screen height:
                if (yCoord > (getHeight() - 30)) {
                    yCoord = getHeight() - 30;
                }

                //check the tooltip doesn't get drawn off the right side of the screen:
                if (contentRight + tooltipWidth < getWidth()) {
                    xCoord = contentRight;
                } else {
                    xCoord = getWidth() - tooltipWidth;
                }

                //draw the tooltip
                graphics.setColor(backgroundColour);
                graphics.fillRect(xCoord, yCoord, tooltipWidth, 30);
                graphics.setColor(borderColour);
                graphics.drawRect(xCoord, yCoord, tooltipWidth, 30);
                graphics.setColor(fontColour);
                graphics.drawText(tooltip, xCoord + 2, yCoord);
            }
        }
        //doRedraw logic prevents infinite loop
        if (doRedraw) {
            //System.out.println("redrawing screen: " + System.currentTimeMillis());
            screen.invalidate();
            doRedraw = false;
        }
    }
}
package mypackage;

import net.rim.device.api.ui.Font;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.Manager;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.PopupScreen;
import net.rim.device.api.ui.container.VerticalFieldManager;

class MyTooltip extends PopupScreen{
    int _x;
    int _y;
    TooltipThread _tooltipThread;

    private MyTooltip(Manager manager) {
        super(manager);
     }
    public void sublayout(int width, int height)    {
        super.sublayout(width,height);
        setPosition(_x,_y);
        System.out.println("Tooltip x: " + Integer.toString(_x) + ", y: " + Integer.toString(_y));
    }
    protected void applyTheme() {
        // Overriden to suppress Border etc.
    }
    public void removeToolTip() {
        if ( _tooltipThread != null ) {
            _tooltipThread.dismiss();
        }
    }
    private void display(UiApplication uiApp, int x, int y, int displayTime) {
        _x = x;
        _y = y;
        _tooltipThread = new TooltipThread(uiApp, this, displayTime);
        _tooltipThread.start();
    }

    public static MyTooltip addToolTip(UiApplication uiApp, String toolTipString, int x, int y, int displayTime) {
        VerticalFieldManager manager = new VerticalFieldManager(Manager.FIELD_VCENTER|Manager.NON_FOCUSABLE) {
            protected void paint(Graphics graphics) {
                graphics.setColor(0x00FFFFFF); // White
                graphics.fillRect(0,0,getWidth(),getHeight());
                graphics.setColor(0x00000000); // Black
                graphics.drawRect(0,0,getWidth(),getHeight());
                super.paint(graphics);
            }
        };
        MyTooltip toolTip = new MyTooltip(manager);
        LabelField label = new LabelField(' ' + toolTipString + ' ', LabelField.NON_FOCUSABLE);
        label.setFont(Font.getDefault().derive(Font.PLAIN, 16));
        toolTip.add(label);
        toolTip.display(uiApp, x, y, displayTime);
        return toolTip;
    }

    class TooltipThread extends Thread {

        Object _notifyObject = new Object(); // Used to allow user to dismiss this Tooltip
        PopupScreen _tooltip; // Screen we are going to display
        UiApplication _ourApplication; // access to pushGlobalScreen and dismissStatus from our Application
        int _displayTime; // in seconds

        public TooltipThread(UiApplication ourApplication, PopupScreen tooltip, int displayTime) {
            _tooltip = tooltip;
            _ourApplication = ourApplication;
            _displayTime = displayTime;
        }

        public void run() {
            _ourApplication.pushGlobalScreen(_tooltip, 999, false);
            synchronized(_notifyObject) {
                try {
                    _notifyObject.wait(_displayTime * 1000);
                } catch (Exception e) {
                }
            };
            _ourApplication.dismissStatus(_tooltip);
        }

        public void dismiss() {
            // notify the waiting object to stop the Thread waiting
            synchronized(_notifyObject) {
                _notifyObject.notify();
            }
        }

    }

}

Tags: BlackBerry Developers

Similar Questions

  • ToolTip for the button previous and next in trainButtonBar

    I'm not able to view the ToolTip for the buttons next and previous by using trainButtonBar. Can someone help me on this?

    Published by: 952401 on August 13, 2012 05:50

    Hey Vinay... I think you can try this
    Required fields in a train

    It was exactly the solution you need.

    Thank you
    Serge

  • Keyboard shortcuts for the buttons works irregularly - why?

    When you use the access key for the button attributes, they work sometimes and not others. Three behaviors are observed:

    -use the accesskey times moves the focus and click on the button (correct behavior)

    -use the access key moves the focus only - do not by clicking on the button

    -use the accesskey does nothing

    These problems occur without change installation, restart, etc..

    What could cause this?

    Moreover, 3.6.28 works very well with the exact same web application.

    It might be useful to have a small script for conducting a census of the keyboard shortcuts page. You can open the web console (Ctrl + Shift + k), paste the following options next to the circumflex accent ("' >" ") and press ENTER. A new element is added at the end of the body with the results.

    var aks=document.querySelectorAll("a[accesskey], button[accesskey], input[accesskey]"); var out=document.createElement("pre"); for(var i=0; i<aks.length; i++) out.appendChild(document.createTextNode("Tag:'"+aks[i].nodeName+"'; id:'"+aks[i].id+"'; name:'"+aks[i].name+"'; key:'"+aks[i].getAttribute("accesskey")+"'\n")); document.body.appendChild(out);
    
  • Need help for the button to trigger on the text caption effect

    Hello world

    I work in

    Screen Shot 2016-04-13 at 12.52.31 PM.png

    on a Mac (chart below)

    Screen Shot 2016-04-13 at 12.53.04 PM.png

    I'm very new to Captivate (only my second week), but am familiar in other Adobe programs. I'm trying to get a dynamic object that I made in a button to trigger an effect on a text caption. I scrolled the forums here and tried various things of the advanced actions for just using the drop down menus in the property inspector and nothing that I tried gives me the result I want.

    Here is a screenshot of what I'm working with.

    Screen Shot 2016-04-13 at 12.54.37 PM.png

    What I want to do is for the arrows for the buttons (and they are currently). When the slide appears first I don't want that image and the arrows visible. So when the user clicks on the arrow, I want the effect I chose (spiral) that will be triggered with the corresponding text.

    Looks like my property for each caption Inspector (the names are different for each)

    Screen Shot 2016-04-13 at 12.58.03 PM.png

    And I also tried to write a few advanced Actions that follow as well as tutorials that I found online, and nothing gives me what I want.

    When I preview the slide I can see everything on entry and then when I click the button to apply the effect. I rechecked the advanced actions and usually when I try these nothing happens at all.

    Is - it there anyway that I can get that works this way, I'm wanting. It seems that it should be simple and I'm right on it.

    The shape of buttons are all pause at this moment, it's OK.

    I just tried it out and see what you mean. The text is there from the beginning, and that shouldn't be the case. you expect it not to appear when the button is clicked. I have never used this spiral effect myself, but since you have no control over it, I mean you can't see where starts the effect at all, there is no visible path you have with the other effects of the entry. Either, you need to create a custom, effect whose path begins with text outside the scene, or a combination of an Alpha to + a standard entrance effect.

    Tried the first one with a simple left to a straight path. I edited the paths so that they all start at the same position horizontal and end at the same horizontal position. So happy with the leaders and Guides that we finally got in Captivate, they are very useful for this type of design:

    It's the chronology:

  • After update to the last version of the space bar no longer give me hand tool / to navigate around my image, everyone knows this? Even for the button on my wacom pen...

    After update to the last version of the space bar no longer give me hand tool / to navigate around my image, everyone knows this? Even for the button on my wacom pen...

    ... computer update restarted... everything seems to work again.

  • When using the 'tools', 'Interactive objects', 'Add a button', how to make the text for the button name is displayed? I have tried everything and only the background, or lacxk, appears.

    I created a pdf document using Adobe Acrobat XI base and want to put a link on each page, return to the table of contents. However, the tool "Add a link" I cannot place this link on each page at a time. Accordingly, I used the tool 'Add a button' interactive Actions that allows me to do what I want. However, when I enter the name of the button, add background color (or not) and register, the name of the text for the button does not show, only the background appears (or nothing if I select no background). The button works, it just is not labeled. Any help will be appreciated.

    This is the area of the label, under Properties - Options.

    The game, 23:02, charlesc90551452, [email protected] , 14 may 2015

  • ToolTip for the oracle Forms button

    Hello

    I'm working on forms 6i with database 10g, there is a button in the form my requirement is when my mouse over this button, it should send a message to the user, I want to implement using ToolTip

    To the help of the indicator built into the message appears in the lower left corner of the form but I want to use the ToolTip, please can someone suggest me how to implement this, I used when mouse enter trigger but it does not work.

    Help, please.

    Thanks in advance.

    Hello
    in help, it has ther tooltip, you can type the message you want to display (for type a message that you typed for the tip). If you want to also set the Visual attribute, you can set (which is below the ToolTip).
    It displays the message at run time when moving closer to this particular field...

  • Accessibility for the button.

    Hi all.

    I have a button that repeats a subform when you click it.  Everything works very well, with one exception, screen readers only read the caption of the button '+' and non-personalized text.

    Using the accessibility palette, I typed an explanation of what the button pressed in a custom text and ToolTip.  Then I put the player screen "Custom Text" priority.  However, (JAWS and Thunder) screen readers read only 'more' and not the custom text.  Am I missing something?

    For now I've added to the text to the caption of the button with the "+" and made the size font 1 and the same color as the button.  I really want to do it for all the buttons.

    Your suggestions and help would be greatly appreciated.

    I use Windows XP and Pro 9 Adobe LiveCycle Designer 8.2.

    Thank you

    Jelf12

    I use the same and find that it works as advertised... can you share the form so I can take a look. Send it to

    [email protected] and include an explanation of the issue with email.

    Paul

  • How can I remove bookmarks on my toolbar when the "bluestar" is not turned on? (Ditto for the button 'delete' in the menu library).

    Dear Sir/Madam
    I had a quick glance at your solutions page and have tried to use all of the tips suggested however, when I try to remove three items on toolbar, none of them illuminate the "BlueStar" located next to their address. (I got rid of other elements). I also tried to remove the Firefox menu library items, however, the button delete them is not on either. I'm now concerned that items are spyware. I thought to reinstall the software, but it would mean losing all my favorites.

    For your information, I've just updated Firefox to 28.0.

    I would appreciate your help with this matter.

    Kind regards
    Suzanne

    Good to hear! I think you should be able to use the trackpad however. I think I remember to make it work on Mac a friends (first one I've listed below, in this web page)-use two fingers and tap the trackpad. I think you might have to watch that you don't type it too lightly, or he doesn't know what you're trying to do.

    On this second which says to use the CTRL, to my memory, the Mac is not that (it does now, maybe)... I think I had to use a different key that was downstairs left... Google Images, I see that there are four: fn, control, option, command... If the control key does not work, my next guess would be to use the option or command key. It's easy to see which experience.

    If you press and hold the function key, and then regular - click on the bookmark you want to delete, isn't that bring up the contextual menu? It's rather than just giving the bookmark two fingers tap.

    • * * * * * * * * * * * * * * * * * * * * * * *

    Use the tap two fingers on the trackpad, not a click, just a light tap with two fingers.

    • * * * * * * * * * * * * * * * * * * * * * * *

    If you have a mouse with a button, hold down the CTRL key, and then click the mouse button.

    If you have a magic mouse, press and hold the mouse on the right side.

    • * * * * * * * * * * * * * * * * * * * * * * *

    Otherwise, go to system-> Trackpad-> Point & Click Preferences and select your preferred option for "secondary click."

  • I deleted accidentally part of the address for the button «back to Homepage» How can I find the normal button please?

    When I click on the button "return to Homepage", only "http://" present in the address bar (the rest was accidentally removed) and an alert shows "invalid address". I tried to enter the address that indicates when the mouse hovers over the button and then it works of course. When I use the button once again, I get the same alert, and a new tab "http://" appears.

    Visit the home page that is displayed in the dialog box options to ensure that it has not been changed. For details on how to see How to set the home page.

  • Character set for the buttons in the UI library (for example confirm Popup)?

    I get my head around the issues of fixed character for my new location requirements.

    How can I control the language of the labels on the elements that are part of the library of CVI user interface such as the 'yes' and 'No' buttons that appear in a window of ConfirmPopup()?  Are they supposed to follow the language of the operating system?

    Thank you

    Ian

    (BTW, it would be great if there is a KB page that gathers the main concepts about the locator tool user interface, several bytes in its chains code, paste the translations of a source such as a Word doc in a .c file, etc..)

    Edit:

    Not sure how I missed it before, but here's a related thread . Do I really need to go and replacements of crafts for the panels of the library?

    Hi Ian,

    Unfortunately, the CVI Run-Time Engine is not localized, and it isn't a very good mechanism to translate the integrated chains of RTÉ. It is possible, but it is clumsy, and it does allow you to dynamically change your language in a program that is already running.

    You must find the strings you need to translate into the message of the BCI (c:\windows\system32\cvirte\bin\msgrte.txt) file. When you see an underscore in the chain feature double character, this means that the following letter is underlined. So if you want to translate the 'yes' and 'No' buttons that serve to ConfirmPopup, you must replace the strings 'today' and '__Yes.

    For more information, read the Programmer's Reference > creation and distribution Release executables and dll > LabWindows/CVI Run-Time Engine > configure runtime > translate the Message file topic in the help of the CVI.

    Note that if you want to distribute a message file results in a distribution of CVI you must check the 'Install custom Run-Time Engine message file' option in the tab Advanced for the dialog box change Installer .

    I understand your point that it is not very good support for localization of the CVI programs, but also why it is not very good documentation for it. It is certainly something that is in the CVI roadmap for future improvement.

    I would like to know if you have any further questions.

    Luis

    NEITHER

  • How can I remove worm of ToolTip for the clayout engine

    What is the program of ToolTip for Clayout engine and how to remove it safely?

    Hi Albertwolfman,

    ·         You receive an error message or error code during the uninstallation of this program?

    I suggest you scan your computer with the Microsoft Security Scanner, which would help us to get rid of viruses, spyware and other malicious software.

    The Microsoft Security Scanner is a downloadable security tool for free which allows analysis at the application and helps remove viruses, spyware and other malware. It works with your current antivirus software.

    http://www.Microsoft.com/security/scanner/en-us/default.aspx

     

    Note: The Microsoft Safety Scanner ends 10 days after being downloaded. To restart a scan with the latest definitions of anti-malware, download and run the Microsoft Safety Scanner again.

    Important: During the scan of the hard drive if bad sectors are found, the scanner tries to repair this sector, all available on which data may be lost.

    Let us know if that helps.

  • Codes for the button layers still CS6

    Successfully, I create my own buttons for Encore CS6.  I note in the layers the character in square brackets to create buttons + just as much! RC = etc. for other functions.  I see not yet included in the website for the forums.  I find it difficult to get detailed Help Menu for buttons.  Given that to enrich Encore Menus in Photoshop, I find myself here.

    Where can I find a complete list of all special characters in the media used in a layer with functional descriptions create button?

    The list is in the help file.

    Adobe still * using Photoshop to create menus

  • ISSUE of MAC - I'm looking for the button toggle for thumbnails

    ISSUE of MAC - I'm looking for the toggle button that allows you to be at the bottom right of your desktop files to increase or decrease the size of the thumbnails.  Is - it still exist?

    Yes. Cmd / (slash) toggles it on and outside.

    Gene

  • Looking for driver for the button change the orientation of the screen on the x 60 tablet.

    I just installed a new OS (Windows 7 64-bit) and I can't find the drivers for a button on the work of the tablet which changes the orientation of the screen.  Help, please.

    I found this, thanks

Maybe you are looking for