Creating and Deleting Individual Buttons
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 08/12/2012 at 13:47, xxxxxxxx wrote:
Hey guys,
I'm having trouble with a programming concept for general button creation and deletion. Not just in C4D. But the concept in general.
Specifically: How can I dynamically make each button an independent object. So that I can create and delete specific buttons. Rather than the last one in the chain.The internet is full of code on how to create and delete buttons as a chain of buttons using increment and decrement with loops. Even the C4D SDK has an example of this in the AsyncTest example. Which adds and deletes rows.
But what do you do if you need to dynamically create or delete a button in the middle of that chain of buttons instead of that last one?I've tried various things with arrays. And I'm always getting bad results after I delete one of the buttons, and then try to add new ones. I get doubles and all sorts of other weirdness.
Rather than trying to re-invent the wheel. I'd much rather learn how other people are doing this kind of thing.Can anyone explain how to do this kind of thing?
-ScottA
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 08/12/2012 at 15:39, xxxxxxxx wrote:
Not exactly sure what you mean. How you technically create buttons is an API specific thing. Works different in C4D, or frameworks like GTK et cetera.
The management of arrays of buttons is up to you. If you store them in an array and you get doubles after changing anything, it sounds like you have a bug in your button management
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 08/12/2012 at 17:45, xxxxxxxx wrote:
Yes.
I'm definitely not writing the array code properly. Which is why I was looking to see if anyone had any advice. Or has done thing kind of thing before.This is what I have:
-A class member array for holding the number of buttons
-Some code in a custom function that creates buttons depending on the values in this arrayIn the GeDialog's Command() function
I have two buttons:- Add new array element(Adds a new button)
- Delete a specific array element(Deletes a specific button)
-I am setting the first array element to a value of 1 in the InitValues() function
-I'm using the Push() function to add new elements to the array using the array's count+1.
-I'm using the Remove(2) function to delete the second element(button) from the array as a test caseWhen I press my Add button. It correctly adds a new element to the array. And a new button is created in the dialog properly.
This part works fine. And it will create as many new buttons as desired.
However..Things go wacky when I click my Delete button to remove the second button. Then try to make more buttons again.
I'm pretty sure I'm doing something wrong with the array handling. But I can't see it.
I'm making all of this up as I go. And could be doing any one a thousand things wrong.-ScottA