TreeViewFunctions select in order of clicks



  • On 02/06/2016 at 15:07, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   13.061 
    Platform:   Windows  ;   
    Language(s) :     C++  ;

    ---------
    Hello!

    I am working in a plugin where I need to know the order of selected elements. Now clicking with cmd, I am able to track order of selected elements. The problem is that if instead of Ctrl I use shift it selects always from element nearest to root despite I select first the item nearest to the bottom of my list.

    What approach do you think should be better to track selected elements in order?

    Now after press shift an select other element it enters to SELECTION_NEW again with nearest element to root and then it uses SELECTION_ADD. Then i get inverted order that I am aiming to get when shift comes from bottom to top.

    Thanks.

    Code used (something like) :

    AtomArray *pAASelectMat;

    void TreeF::Select(void * root, void * userdata, void * obj, LONG mode)
    {
    if (!GetActiveDocument())
    return;
    BaseMaterial *bmat = __GETBASEMATERIAL__(obj);

    switch (mode)
    {
    	case SELECTION_NEW:
    			AAmaterial->Flush();								// clear the atomarray
    			AAmaterial->Append( bmat );
    		break;
    
    
    	case SELECTION_ADD:	
    			if(AAmaterial->Find(bmat) == NOTOK)
    				AAmaterial->Append( bmat );
    		break;
    
    
    	case SELECTION_SUB:
    			AAmaterial->Remove( bmat );
    		break;
    }
    

    }



  • On 03/06/2016 at 08:43, xxxxxxxx wrote:

    Hi and welcome to the PluginCafe forums!

    TreeViewCustomGui selection also depends on the implementation of TreeViewFunctions::IsSelect().
    Your issue may well be generated by how you process the selection and AAmaterial array in this function.



  • On 09/06/2016 at 13:44, xxxxxxxx wrote:

    Thanks by your welcome.

    Basically I return if my BaseMaterial BIT_ACTIVE is different than 0 in the IsSelected function implementation.
    But I realize also it comes in same order from top element to bottom. Also I realize is same behaviour if I select from bottom to up dragging a rectangle area in that direction. It scans elements and detects selection from top to bottom. Is this selection order behavior to detect order to select possible? I mean I can see rectangle being drawn but it doesn't select elements while dragging it does when I release mouse button and detects it from top to bottom elements selected.



  • On 09/06/2016 at 15:09, xxxxxxxx wrote:

    @sotoahs - If memory serves this is a limitation of how C4D processes Shift+Click and Rectangle Drag selections. Using GetActiveObjects w/ the Selection Order flag gives the same bad results for Rectangle/Shift select.



  • On 09/06/2016 at 15:11, xxxxxxxx wrote:

    You may somehow be able to manually rewrite the selection logic by overriding all click handling, and tracking which object was last-selected in order to extrapolate selection order. It's something I've contemplated but have opted not to do because it felt like too much work.

    - Donovan


Log in to reply