PAC Display: Button Z-index bug


I have a button control on a form and depending on the state of a Controller variable I want to change what text is displayed on the button. This isn’t currently possible so instead I thought I’d use a hack and place a Text object over the button. This revealed a bug in the z sorting: as soon as you mouse over the button (triggers a repaint for the pretty effect) the button is painted over the text object.

Here is a video (cropped to a reasonable size, hopefully there is still enough context)

Note: I’ll be adding a separate post to request that we drive the text attribute of the button control from points and variables.



Instead of using a “button control”, try it with a shape instead (rectangular with rounded corners can look nice). I’ve found that the Z-order between text objects and shapes is maintained. Through the dynamic attributes of the shape, you can make it change colors while being pressed to give the visual feedback.


Here’s what I’ve been told on this “known issue”:

No there is currently no way to do [this] …the Z-order is always on top for windows controls (combobox and button). This is documented.

Wish I had better news. Of course, you can make your button look however you want by using a shape, as mentioned.


Thanks for the suggestion. I’m new to PAC Display so I could be missing something basic here, but how would you change the color when the button is pressed? The only way I can think to do this would be to have chart logic (or OptoScript) that would modify a variable to represent the depressed duration. So the user clicks the button and a SendValue command causes some chart logic to set a variable, say “buttonDownTimer” to 100ms and then Display has the background color driven by this variable. After 100ms the Controller resets the variable value and Display will change the background color.

That can’t be the correct way to do it. How did you handle the pressed background change effect without the Controller?


Thanks for the follow up. I figured the text object was a WinForms Label control and would play nice with the button and others but it sounds like maybe it’s an owner drawn custom control. Transparency can be difficult in those cases. For me it’s now moot after you pointed out the fact that a button CAN have it’s text driven by dynamic attributes when the “#” is present.


It can be done without chart logic. In the “Send Discrete” dynamic attribute, if you choose “Fixed Data” as the source, you are given some options for how that data is sent. Choosing “Direct” means that the data is sent only while the button is being pressed. You can then use the graphical dynamic attributes of the button to adjust how it looks based on value of the tag that was affected by the direct button. For me, it works out that I haven’t need to create any tags for the sole purpose of controlling button graphics, but even if you have to add some tags, at least there is no need to involve the controller strategy.