Home AMX User Forum AMX Control Products
Options

Button creation on the fly

I have to create a page with a number of buttons. The trick is that initally (at the moment of page creation) number of buttons is not known and must be defined later (in run-time) by Netlinx code.

Any idea how to achive the goal in the most effective way?

Indeed, this is a well known situation for SAT decoder channel list... Thanks in advance for all the comment...

Update: this is for G4.

Comments

  • Options
    DHawthorneDHawthorne Posts: 4,584
    If you look at the programming section of a panel manual, you will see there are a raft of commands to dynamically set and adjust both buttons and pages, including showing and hiding buttons altogether. Support for various functions varies by panel. The most loaded function is ^BMF, but there are others that do a wide variety of things.

    However, I don't think you can create, resize, or reposition buttons in code, just hide or show them. Which perhaps is just as well, so you can assure some level of pleasant appearance. I undertand you once could create an entire panel in code by sending commands to the panel, creating pages and buttons on the fly and destroying them as you move on...at least I recall stories of someone doing that in a training class. This guy purportedly just plugged a blank panel in, and the controller (Axcent series yet) drew the screens.

    That's just too much work :).

    What I do is set an upper limit on the number buttons I want available, create them all, and place them on the page in such a way that I can make them vanish without making it look funky. I make them multi-state bargraphs with three states (though I have more on occassion) - completely transparent, off, and on. Then I track in code which buttons will be active . The ones that are not, I send the level to them that makes them transparent, and ignore any pushes that might come in on them. the ones that are get the appropriate level for their state. This gets ugly when you have a lot of buttons, there is no graceful way to put 30 buttons on a page, then make all but 3 vanish. So I generally only do this when I have a function that might become unavailable under certain conditions. Sometimes I'll have a grey state for it, and sometimes I'll just make it vanish.

    The other thing I have done with dynamic buttons is take the opposite approach - put just a few buttons on a page, and treat them like a sliding index to the total data set. If you have five buttons on a page, and 100 functions (which could be channels, or media tracks or titles), your top button indicates where in the list you are - if you are at the top, it's number one. If you are ten pages down, it's number 45. You then send a variable text based on that position to label it, and interpret the PUSH based on the index. You also will need page buttons to scroll through the list and update the index. The nice thing about doing this is that your data set is extremely flexible, and you don't have to change your panel when thedata changes.
  • Options
    JoeJoe Posts: 99
    I've run across situations where buttons need to appear or disappear from a touchpanel. Most of the touchpanels I design incorporate some sort of graphical background, so some may find this approach a bit tedious, but it works well.
    I use popup pages to show or hide buttons. If there is a single button I need to make disappear, I will draw a new button around it, move the original out of the way (write down the coordinates so you can put it back exactly where it goes), make the fill on the new button transparent, then use a screen capture program to take a snapshot of the transparent button. Save that as a bitmap, create a new popup page the same dimensions as the transparent button, then use the new bitmap as the background. It sometimes takes a few tries to get it to match perfectly, but once you get it, it's great.
    Second, if you need a bunch of buttons to appear on a page, use the above method to create a few or several popup pages with the buttons needed. Then you can make them appear or disappear as needed from the code.
  • Options
    Spire_JeffSpire_Jeff Posts: 1,917
    I use the ^BMF function with no problems (once I figure out where I screwed up the formatting). All of the touchpanels I design to control multiple rooms use a limited number of buttons and the buttons are named via the processor. It does add to the work in programming, but if you develop a standard approach, you should be able to utilize this base code everywhere. I have it so that the only thing I change is the button text and the visible/not visible states that way the graphics guy can design till his heart is content and the panel still works (obviously he has to lay things out accordingly, but I don't have to change code every 2 minutes)

    Jeff
Sign In or Register to comment.