On 20/04/2018 at 02:40, xxxxxxxx wrote:
Cinema 4D Version: R19
Platform: Windows ;
Language(s) : C++ ;
I've looked into the documentation, but cannot seem to find details related to this topic.
I have a GeDialog which I populate dynamically with buttons. To know which button gets pressed by the user I use a base ID + index value.
Let's say button 1 has ID 1000, button 2 has ID 1000 + 1, etc ...
This way, in the GeDialog::Command I simply need to subtract 1000 from the incoming ID to know which button got pressed and react accordingly.
Additionally, the user can remove buttons. This would introduce gaps in the index, if I simply remove the button, so I would like to adjust the ID of the remaining buttons (after the one being removed) in order to avoid an index gap.
I thought of simply removing all buttons from the one being removed till the last one, and re-adding the buttons with re-indexed values.
But if it's possible to simply change the gadgets' IDs I'd be happier to do so.
On 20/04/2018 at 03:53, xxxxxxxx wrote:
Well, I guess we can close this topic since it doesn't make much sense.
Working on the rest of the implementation for the dialog, I encounter a much bigger problem.
The buttons I dynamically create are part of a group in the dialog.
I can remove a button without problem, but I cannot simply add a button to that group, as it gets added as the last item in the dialog. Which means the new buttons get added after the last gadgets of the dialog.
I assumed I could simple set the the focus to the group by calling Activate(groupid), and continue adding gadgets to that group. But that's apparently not the way things work.
So, instead I need to flush the whole group and add all items again.
Which, from one point of view, is good since then I don't need to update the IDs of the gadgets. Now I simply recreate them all over again ... with updated index.
On 21/04/2018 at 01:12, xxxxxxxx wrote:
if removing buttons is simple and your problem is only IDs, use std::map at the start and your life will be easier
On 21/04/2018 at 08:50, xxxxxxxx wrote:
What I meant was that dynamically removing a button from a group is possible, but not adding one. So the whole idea behind updating the IDs is of no use.
On 21/04/2018 at 09:11, xxxxxxxx wrote:
I think you can hide them dynamically (but they remain there, not drawn).
On 23/04/2018 at 07:40, xxxxxxxx wrote:
just chiming in to add a few links.
It's correct, in order to add to a group the correct way is to flush (LayoutFlushGroup()) and then rebuild it.
The Activate() function changes the focus for the user. So, it activates a certain widget, which can then for example directly be controlled by keyboard input. It's not meant as "programmatic focus". Let me know, if you think, we should improve the docs here.
And finally the inevitable manual link: GeDialog manual (Groups)
On 23/04/2018 at 11:50, xxxxxxxx wrote:
Documents are clear as they are.
I understand the Activate() function was only meant to set the focus for the user, but I just hoped that it did (behind the scenes) allow for "programmatic focus". It was worth a shot trying.
Also, thank you Mohamed for trying to help out. It seems I didn't mention an important point in my introductory message. I needed the user to allow to remove buttons, but forgot to mention the user also should be able to add buttons. And all this in a non-particular order.
So while the RemoveElement() function is available (at any point in time), there is no way to add an element somewhere in particular (an Addxxx() is always added at the end of the GeDialog).
Topic can be closed