452 views
in Embedded Wizard Studio by

Hello,

I am trying to add some components as View programmatically to a class with an Outline. Before adding these components I set them to Embedded = true. But when I want to loop over all Views (FindNextView) the property Embedded is false. What is the reason for this? How can I extract the View added to the Outline. I want to ignore all Views which are not Embedded and assigned to the Outline.

Owner:

var Lists::Item item = new Lists::Item;

item.Embedded  = true;        
item.String    = aString;

PopUp.Add( item, nrOfItems );

nrOfItems = nrOfItems + 1;

Class with Outline:

var int32 i;
var Core::Group item = (Core::Group)FindNextView(null, Core::ViewState[ Enabled, Visible, Focusable ]);

for ( i=0; i<CountViews(); i=i+1 )
{
  if ( (item != null) && (item.Embedded == true)  )
    // do something;
                        
  item = (Core::Group)FindNextView(item, Core::ViewState[ Enabled, Visible, Focusable ]);
}

Thanks, Jonas 

1 Answer

0 votes
by
 
Best answer

Hello Jonas,

according to your implementation, you iterate over all views existing in the component (within the class). If you want to iterate over the views controlled by an Outline only, invoke the method FindNextView() method in context of this Outline object. For example:

var int32 i;
var Core::Group item = (Core::Group)Outline.FindNextView(null, Core::ViewState[ Enabled, Visible, Focusable ]);

for ( i=0; i<CountViews(); i=i+1 )
{
  if ( (item != null) && (item.Embedded == true)  )
    // do something;
                        
  item = (Core::Group)Outline.FindNextView(item, Core::ViewState[ Enabled, Visible, Focusable ]);
}

See also the documentation: Enumerate and search views controlled by the Outline Box.

Does it solve the issue?

Best regards

Paul Banach

by
Thank you, it works, but I have to call Outline.CountViews().

Can you explain the different behavior, when retrieving the component from FindNextView() and Outline.FindNextView(). Is it just the Embedded property, or are there more differences? When do I have to to access the component via the Outline and when via the class (f.e. when I want to delete it)?

Another confusing behavior is, that in the Variables window the property Embedded = false. But in fact the item passed the if-statement.
by

Hello Jonas,

you are right, I have overlooked the invocation CountViews. It should also be invoked in context of the affected Outline object.

Concerning the difference, the methods provided by Outline view do limit to views belonging to the affected Outline only. A view is considered as belonging to an Outline if all following three conditions are true:

1. the view has the property Embedded set true

2. the view is arranged in front of the Outline view

3. there is no other Outline view separating the both. In such case the view would belong to the second Outline.

You use the Outline version of the methods (e.g. FindNextView) only if you want to restrict the search operation to views controlled by the Outline. This has no effect on the Add/Remove operations. To remove a view you do this always in context of the GUI component the view (and the Outline) belong to.

Technically, Outline does not manage the associated views by itself. The views are managed by the GUI component only. Outline provides only a kind of technique to identify the views associated to it, to arrange and scroll the views. The views, however, continue belonging to the GUI component.

Concerning the observation in Variables window, this effect is known. The Variables window displays the contents stored in the memory associated to the property Embedded. The property Embedded, however, determines its contents dynamically from an internal viewState variable. Similar occurs to the property Visible or Enabled. We plan to modify this special behaviour in further versions.

Does it help you further?

Best regards

Paul Banach

by
Yes, this helps a lot. Thank you very much.

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...