06-20-2012 05:02 PM
Fundamentally, I would like to discard clicking in the body of a STRING indicator, but allow the user to use the vertical scrollbar. When I discard clicks in a "Mouse Down?" event, it also prevents scrollbar use.
I haven't found a simple way to do that, so I hard-coded a scrollbar width of 12 pixels and discarded clicks that were >12 pixels to the right of the control's right bound. But I hate hard-coding constants like that; it would be much better if I could programmatically determine the width of the scrollbar.
Any suggestions for determining the scrollbar width? Alternatively, any superior methods for discarding clicks in a STRING indicator while still giving access to the scrollbar?
06-20-2012 05:33 PM
Set the Selection to 0,0 on any keystroke or mouse down/up event... though it's still not super elegant.
06-20-2012 06:43 PM - edited 06-20-2012 06:45 PM
When I want something quick and dirty I'll just slap a transparent picture control over the top of the area I want to block from clicks. Grouping the controls can help when you move things around. In this case cover the text portion of the indicator, but not the scrollbar region. No math, no code.
Edit: forgot to mention the other added bonus, no cursor changes which give the false impression that you can click in the first place.
06-20-2012 06:45 PM - edited 06-20-2012 06:46 PM
Darin, I had exactly the same thought, but I ran into the same basic problem: I don't know how wide the scrollbar is, and therefore can't distinguish between total control width and scrollbar width. Unless I'm misunderstanding your suggestion?
EDIT: I should clarify that the size of the string indicator changes dynamically, depending on how the Dialog VI is called.
06-20-2012 06:46 PM
See, this is why we keep these guys around. Simple and elegant 🙂
06-20-2012 06:50 PM
I may be missing something, you simply draw the picture control to be the proper size.
06-20-2012 06:53 PM
I added an edit in the original comment, but basically the string indicator gets resized depending on how the dialog sub-VI is called. I do all the control arrangements dynamically.
I'd also be worried about the width of the scrollbar varying depending on the computer it's deployed on. Wouldn't that potentially mess with the transparent control alignment?
06-20-2012 07:09 PM
How are you resizing? This method works fairly well if you scale objects with the pane. If you are forced to do math, I think you will always have frames and other offsets to worry about. One other suggestion is to stick to the system string, I think it is the cleanest.
06-20-2012 07:15 PM
Basically, it's a generic "prompt" dialog. I load whatever text I want, sometimes just a short warning message, sometimes multiple paragraphs.
After the text is loaded into the Message string control, I call a Size to Text Invoke node.
Then I check the height of the string control. If it exceeds a certain threshold (currently 75% of the monitor vertical resolution) then I size it down to the max limit and toggle the vertical scrollbar on.
Let me know if any of that was unclear or if you need more info.
06-20-2012 07:31 PM
I see, turning the scrollbar on and off will be a bit of an issue. I suppose you could either dynamically size the picture control, or systematically calculate the click coordinates, either way you are going to be stuck with a fudge factor I think. It should be fixed since you are dealing with pixels, unless you also allow the width to scale with pane size. There are some properties with scripting to get the text bounds, but none of them give you exactly what you would want (as far as I know), and you will simply have different constant offsets.