How to select and modify the object at runtime?

103 views
asked Mar 13 in Embedded Wizard Studio by Andy
Hi,

At runtime, I use KeyHandler(Enter) to add many Triangles(var Views::WarpImage image = new Views::WarpImage;) in the screen.

How can I select these triangles to modify there attributes ( like Visible,Point,Rotate...) by using another keyHandler?

1 Answer

0 votes
answered Mar 13 by Paul Banach
 
Best answer

Hi,

you can add a second key handler and configure it to react on cursor keys only (Left, Right, Up, Down). Then you will need a variable (e.g. CurrentView) to store in it the actually selected view. When the cursor key handler is triggered, you use the method FindViewInDirection() to locate another sibling view, which should become selected. The operations to modify the attributes of the view (Visible, Rotate, ...) are performed on the view stored actually in the variable CurrentView.

Does it help you?

Best regards

Paul Banach

commented Mar 14 by Andy

Hi, Paul Banach

Thanks it helps me a lot.

But I have another  two questions

The following picture is my Screen

a white small point is my cursor controled by Left,Right,Up,Down

Now, I use Tab Key to select the triangles by using  FindNextView().

Is it possible when I move the cursor to a triangle and press a key then I can select this triangle?

If yes, how to implement it ?

Second,

My Tab key code is below

var Core::View view = FindNextView( Focus, Core::ViewState[ Enabled, Focusable ]);
if ( view == null )
  view = FindNextView( null, Core::ViewState[ Enabled, Focusable ]);
if ( view != null )
  Focus = view;

But my triangle object is var Application::TriangleAttribute image = new Application::TriangleAttribute;

In variable view I can't find the triangle's attribute.

Thanks!

 

Best Regards,

Andy Dong

commented Mar 14 by Paul Banach

Hello Andy,

please see the article Enumerate and search views existing within the component. It describes many different methods to find a view. In your concrete case you would need the method FindViewAtPosition.

In order to access the members of the Application::TriangleAttribute you have to type-cast the variable view. The type-cast verifies at the runtime, whether view in fact does refer to an instance of the expected class. For example:

var Core::View view = FindNextView( Focus, Core::ViewState[ Enabled, Focusable ]);

[...]

// Cast the generic 'view' to concrete class 'Application::TriangleAttribute'
var Application::TriangleAttribute triangleView = (Application::TriangleAttribute)view;

// If the cast was successful, you can access the members of the triangle object
if ( triangleView != null )
  triangleView.XYZ = 1234;

Best regards

Paul Banach

commented Mar 15 by Andy
Hi, Paul Banach

Thanks for your help!!

 

Best Regards,

Andy Dong
commented Mar 22 by Andy

Hi, Paul Banach,

I have new questions

1.

As above picture,

All these triangles are generated dynamically

 I select one of these triangles ( called A ) and move it.

The relative position between A and other triangles will be the same as the orignal

Is there anyway to implement it ?

2.

like the following picture

I can slide Left or Right to swtich different VerticalList

Is it possible to use VerticalList in HorizotalList ? 

Or is there anyway to implement this function?

 

Thanks!

Best Regards,

Andy Dong

 

commented Mar 22 by Paul Banach

Hello Andy,

concerning your first question, I don't understand the expected behavior. Do you want to move several triangles at once so the distances between them don't change? In such (or similar) case you will need to implement your own algorithm which evaluates (and modifies) the position of all triangles existing actually in the component. Use the methods FindNextView, FindPrevView, FindViewInDirection, etc. for this purpose.

Concerning the usage of list views, you can create a GUI component containing a Vertical List and use this component as item for a Horizontal List. In this manner you can nest one list inside another.

Best regards

Paul Banach

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

...