Announcement

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

    Can I add a counter label to a button

    I have a tool strip with buttons and for one of them I want to periodically show a number of records in a small box (just like the highlighting of unread messages in e-mail clients). I've been able to create something, but this is not very handy and it doesn't update when I resize the window.
    Click image for larger version

Name:	buttons.png
Views:	26
Size:	2.4 KB
ID:	262565


    I use a Label for the red box and I call label.moveTo(otherWidget.getPageLeft(), otherWidget.getPageTop()) to position it. Is this the way to go or can I use snapTo?

    #2
    Yes, we would recommend using snapTo. Since the typical "badge" appearance is to extend slightly outside of the badged icon, we could recommend making the label a peer (a child cannot extend outside of its parent).

    Comment


      #3
      I have no idea how to create the label as child of that button, but I guess you mean it should be a sibling ("neighbour") of that button and thus a child of the tool strip that contains the button? If so, how would I position the badge at more or less the same place as the button? To which component do I need to snap the badge? And which value do I need for the "snapTo" option? I believe it can only be snapped to the corners and edges of a parent element? How to create an offset then? I mean, if it is a child of the tool strip, then this badge obviously hasn't "TR" or "TL" as "snapTo" value.

      The screenshot I sent was created using a label and calling moveTo(button.getPageLeft(), button.getPageTop()). If I resize the window, the badge is not moved, while the button is.

      Comment

      Working...
      X