Jump to content

Recognise number of element added to array


_Y_

Recommended Posts

UI has an array. A new element can be added initialising one more element at the end or using menu "Insert element before". Both methods launch user event "Value Change".

 

Is any way to see index of newly added element? My guesses are limited to watching position of mouse clicks but there is no fun is such a solution.

Edited by _Y_
Link to comment

What I normally do is to compare Old and New Value and look for the first nonequal element.

post-28229-0-90203400-1429600821.png

If the new element is added at the end of the existing, off the head the boolean array will be short as the Old, but the increased length will asess the change in the last element.

Edited by ensegre
Link to comment

look for the first nonequal element.

 

Unforttunalely, it does not work if a new element is iserted near an old element and both have default value.

 

The simplest example is inserting in Boolean array where all elements are False. The method will say that the element is added at the end independently on the actual insertion position.

Link to comment

Right. But then one could argue, is it really important to evidence where the mouse has been clicked, or just how the resulting array differs at all?

 

One workaround I could think (maybe), is the following: make an array of clusters, [ordinal,your_content], where "ordinal" is a flag, for example an integer which defaults to -1 and is set to the element number by the Value Change event. In the GUI you could hide "ordinal" if it falls in the way. Then finding the insertion translates into finding the first -1 in New Value, finding a deletion means finding a jump of 2.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.