448 views
in GUI Development by

Hello, 

I have a question, I use an outline box and fill it with pushbuttons. 
The filling follows when I switch to the page.

Now the problem is, when I click again on the site it adds the existing pushbutton with the new pushbutton 
Means: 2 existing pushbuttons which are already present in the outline are added with 2 more = 4

We have already tried it with "FindSiblingView" unfortunately also without success

Is there somehow a way to completely delete the content of the outline box before I reload the content (The content is variable )

in the lower area you will find a few photos I hope it is understandable what I mean :-) 

Thanks in advance, I hope you can help me how I could do this best. 

Cheers 
Simon 

Here the OutlineBox is filled and passed on to the Application OutlineList


 

Creating the pushbutton in the OutlineBox. 

When you click again on the page it jumps to the RemoveItemes 

We have tried to delete the content with the FindSiblingView but without success. 

1 Answer

0 votes
by

Hi Simon,

I think (without trying it or without debugging your application) that FindSiblingView( this, ... ) will return null, because you are searching for a sibling view of the Outline box instead of an embedded View.

Try the following:

/* search for the first embedded view of the outline box */
var Core::View view = Outline.FindNextView( null, Core::ViewState[ Embedded ] );
while ( view != null )
{
  /* make sure that it is a button and remove it */
  if ((Application::ErrorItemsButton)view != null )
    Remove( view );

  /* search again for the first embedded view */
  view = Outline.FindNextView( null, Core::ViewState[ Embedded ] );
}

Does it work?

Best regards,

Manfred.

 

by
Hi Manfred,

It works greate , thank you very mutch for you help

Cheers
Simon
by

Dear Embedded Wizard Team,

I have a question regarding the toggle functionality in my project. I have implemented a toggle item, and within the toggle function, I am trying to dynamically add or remove a view. Below is a simplified version of the code I'm using:

 

var Menus::TemperatureInputChannel3 itemView = new Menus::TemperatureInputChannel3;
if (TemperatureInput.Active)
{ Add(itemView, 0); }
else
{ itemView.Remove(0); }

The Add function works correctly when TemperatureInput.Active is true. However, when TemperatureInput.Active is false, the Remove function does not seem to remove the item as expected.

My intention is to remove the itemView when it is no longer needed. Could you please suggest the correct way to achieve this? Is there something I might be missing?

Thank you for your support.

Best regards,
Vinoth W.

by
Hi Vinoth,

first of all, let me recommend to add a new question for a new topic...

According to the code snippet you have shared, you create a new instance of the class Menus::TemperatureInputChannel3 then you want to remove it in case that Active is false. This will lead to a runtime error, because you want to remove a view that was never added.

Does this answer your question?

Best regards

Manfred.
by

Hi Manfred,

Thank you for your response.

To clarify my question: I am trying to remove the view that I previously created and added during the first toggle of the TemperatureInput component.

On the first toggle, I successfully create and add the Menus::TemperatureInputChannel3 view. However, when I toggle again (i.e., when TemperatureInput.Active becomes false), I am unable to remove the same view that was added earlier.

My question is: how can I properly remove the previously added view during the second toggle?

Thank you for your guidance.

Best regards,
Vinoth W.

by
Hi Vinoth,

in this case you should save the perviously added instance in a variable and remove the stored instance later. In the code snippet you provided, you have created two instances: One instance that was added and one instance that you intended to remove. This will not work. The operator new creates a new instance and does not provide an access to a previously created instance.

Hope this helps.

Best regards,

Manfred.

Embedded Wizard Website | Privacy Policy | Imprint

...