Programatically Change Component Action


Recommended Posts

I'm using a large number (64) of small panels on a page with backgrounds that vary based on certain events. A sequence loops through the component names using an execute statement that sets the color, like execute("component.panel" + doubletostr(n) + ".backcolor = 255"). This works great. For aligning all of these and their related display fields, I use an editing sequence that also runs the execute and sets the .Position Left and .PositionTop properties for each panel so they all jump into line (the layout.align function is not able to do this due to the complexity) That works fine too. But now I want to take an action that is different based on the panel position, but I'm too lazy to manually enter quick sequence actions for each of the panel components ( I wrote a little class method button.Action(PanelNo)). Is there access to the component property such as component.strAction, or component.panel3.strQuickSequence ="button.action(3)" ? Or just wishful thinking? I know sometimes there are undocumented yet very useful tools around! (like db.querytoclass!)

Link to comment
Share on other sites

There is no programmatic access to the Action on a control. There are a couple ways to do it, both very similar:

1) create a sequence function that takes a parameter with the panel #. Then, set the action of the panel to myFunction(1) changing the 1 to 2, 3, 4, etc for each panel. Its slow to setup, but you only have to do it once, and it probably will only take 10 minutes. Then you can edit the functionallity of all your panels just by changing the one sequence. The action remains the same.

2) you can do this a little easier by using a local configuration variable, then using that variable in your quick sequence instead of hard coding 1, 2, 3. Then you can open the docking properties window and edit that value from there instead of having to open the component specific properties popup and switch to Action to make the change. Truthfully, with 64 components, option 1 is just fine.

Link to comment
Share on other sites

Option 1 is what I'm doing; I was just hoping to avoid all the clicking to setup the actions. There are 64 panels, but each one also has 3 hot spots, so there are really a total 256 actions that have to be edited by right clicking to select properties, picking the action tab, scrolling the combo to quick sequence, then pasting the function, then clicking ok. So a thousand clicks or so, more than 10 minutes, like I said I was just lazy and trying to avoid all that. Maybe we can add programmatic action access to the futures list!?

Link to comment
Share on other sites

Its easier if you create one component, give it a name like myComponent1, then duplicate it 64 times. That will auto-name them 2, 3, 4, etc. and you only have to open properties, click Action tab, change the number and hit ok since Quick Sequence would already be there along with your function call. Don't put the actual function code there, otherwise if you want to change it sometime, you'll have to repeat 64 times again.

You could also use the OnLButtonUp system event to just see if someone clicked inside the panel.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.