No announcement yet.
  • Filter
  • Time
Clear All
new posts

    Setting ButtonItem prompt

    In SmartClient 8, I am trying to dynamically modify the tooltip text for a ButtonItem. It is set originally in the prompt property of the ButtonItem constructor. Then at some point, I change the title and the prompt for that item. The title changes but hovering over the button still gives the original prompt string. So far, this is what I've found:
    Say the ButtonItem is called "isc_ButtonItem_1.
    My code is something like this:
    isc_ButtonItem_1.setTitle("New Title");
    isc_ButtonItem_1.prompt = "new tooltip";
    This causes the title of the button to change but the hoverover text is still the same. Checking the prompt property of the ButtonItem shows that it has been changed.
    Looking at the page with the Developer Console, it appears that when you hover over a ButtonItem, you are actually hovering over a ButtonItem_button. So in my example, I see the object being identified as
    So if I change the prompt property of isc_ButtonItem_1_button, then the hoverover text is appropriately changed.
    So my question is, how is one supposed to dynamically change the prompt string? Is this a bug?

    Hi sdixon,
    Looks like we're missing an API here.
    We'll add a "setPrompt()" API to the ButtonItem class to take care of this properly in the 8.x branch. This will show up in nightly builds going forward.

    However for now, you can work around this as follows:

    ButtonItem is a subclass of CanvasItem that creates a live Button widget as its canvas.
    So you can simply call 'setPrompt' on the buttonItem's button:
        <yourButtonItem>.prompt = "New Prompt";


      A quick update to note that we've added that API to the SmartClient 8.x branch and to the SmartGWT 3.x branch.
      Developers working with 8.x (or SGWT developers working with 3.x) will have this API in nightly builds going forward.
      Developers working with SmartClient 8.1 or SmartGWT 2.5 should use the approach described here to get the same effect.


        That did the trick for now. I just put in a check to see if setPrompt exists for the ButtonItem and use the workaround if not. Should work going forward that way.