Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » Shift-key Selection Functionality Collapse All
Subject Author Date
Krustys Donuts May 12, 2008 - 11:19 AM

I am using a CTreeGridWnd. I have the __EGBS_SFB_FULL_ROWS flag set. This configuration is getting me the desired functionallity with one exception. When a row is clicked, the clicked-on row is selected and all other rows are deslected. This is great. My problem is when a row is clicked while the SHIFT key pressed, the selection state of the clicked-on row is toggled and all other rows remain in the same selection state. I would like this behavior to be provided by the CTRL key, not the SHIFT key. What is the best way to make this change?


Thanks,


Gil

Krustys Donuts Aug 26, 2008 - 12:25 PM

Sorry about the incomplete code snipet. Below is the complete routine.


 



///////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////

bool

UINT nChar,

VRTeachpointGrid::OnGbwAnalyzeCellMouseClickEvent(// VK_LBUTTON, VK_RBUTTON or VK_MBUTTON only

UINT nRepCnt,

// 0 - button up, 1 - single click, 2 - double click, 3 - post single click & begin editing

UINT nFlags,

// mouse event flags

CPoint point

// mouse pointer in client coordinates

)

{

ASSERT_VALID(

ASSERT( 0 <= nRepCnt && nRepCnt <= 3 );

 

{

 

this );if( nChar == VK_LBUTTON )//If the user is pressing the CTRL key.

 

{

if (CExtPopupMenuWnd::IsKeyPressed( VK_CONTROL ))

// HandleCtrlClickSelection(point);

// return false;

}

 

//If the user is pressing the SHIFT key.

 

{

else if (CExtPopupMenuWnd::IsKeyPressed( VK_SHIFT ))

// HandleShiftClickSelection(point);

// return false;

}

CExtGridHitTestInfo htInfo( point );

HitTest( htInfo,

 

 

 

false, true );if (htInfo.IsHoverEmpty() || (! htInfo.IsValidRect() ))return false;//If the user has clicked on an inner cell.

INT nColType = htInfo.GetInnerOuterTypeOfColumn();

INT nRowType = htInfo.GetInnerOuterTypeOfRow();

 

{

 

&& OnTreeGridQueryColumnOutline( htInfo.m_nColNo )

&& (htInfo.m_dwAreaFlags&__EGBWA_TREE_OUTLINE_AREA) != 0)

&& (htInfo.m_dwAreaFlags&(__EGBWA_CELL_BUTTON|__EGBWA_CELL_CHECKBOX)) == 0)

{

HTREEITEM hTreeItem = ItemGetByVisibleRowIndex( htInfo.m_nRowNo );

 

|| ((htInfo.m_dwAreaFlags&__EGBWA_TREE_BOX) != 0))

{

OnTreeGridToggleItemExpandedState(htInfo.m_nRowNo, &htInfo);

 

}

}

 

if ((nColType == 0) && (nRowType == 0))if (( (nRepCnt == 1)if (((nRepCnt == 2) && (hTreeItem != NULL) && (ItemGetChildCount( hTreeItem ) > 0))return true;//If the user has single-clicked on one of the inner cells.

 

{

 

else if ((nRepCnt == 1) && (htInfo.m_dwAreaFlags & __EGBWA_INNER_CELLS))//If user has clicked on one of the cells in the approved or orientation columns.

 

{

 

if ((htInfo.m_nColNo == kPlateAndA1OrientCol) || (htInfo.m_nColNo == kApprovedCol))//Make sure this cell is of the correct type.

VRCellPicture* pCell =

 

{

HTREEITEM htiItem = ItemGetByVisibleRowIndex(htInfo.m_nRowNo);

string strTpName = GetTpName(htiItem);

VRTeachpoint tp = m_modTpList.GetTeachpoint(strTpName);

 

dynamic_cast<VRCellPicture*>(GridCellGet(htInfo));if (pCell != NULL)//If this TP is locked, don’t allow the change.

 

{

string str = (boost::format(st.GetString( IDS_strLockedTpErr)) % strTpName).str();

AfxMessageBox(str.c_str());

}

 

if (tp.GetLockedFlg())else

{

 

tp.ToggleA1Orientation((UINT)pCell->LParamGet());

 

tp.ToggleApprovedFlg((UINT)pCell->LParamGet());

ModTeachpoint(tp.GetName(), tp);

}

}

}

}

}

 

if (htInfo.m_nColNo == kPlateAndA1OrientCol)else if (htInfo.m_nColNo == kApprovedCol)//Single click on name header cell. Reverse sorting.

 

(htInfo.m_dwAreaFlags & __EGBWA_OUTER_TOP))

{

m_bAscendingOrder = !m_bAscendingOrder;

SortTps(m_bAscendingOrder);

}

}

else if ((nRepCnt == 1) && (htInfo.m_nColNo == kNameCol) &&// if( nChar == VK_LBUTTON && ( nRepCnt == 1 || nRepCnt == 2 ) )

 

 

if( nRepCnt == 2 )return

CExtGridWnd::OnGbwAnalyzeCellMouseClickEvent(

// not CExtTreeGridWnd

nChar,

nRepCnt,

nFlags,

point

);

 

return

CExtTreeGridWnd::OnGbwAnalyzeCellMouseClickEvent(

nChar,

nRepCnt,

nFlags,

point

);

}


Thanks,


Gil


Technical Support Aug 27, 2008 - 11:50 AM

We tried to copy the method source code from your message into Visual Studio’s C++ source code editor for further code formatting, analysis and testing but we noticed that many lines in your code snippet are swapped with each other. For instance, the first three code lines are:

bool
UINT nChar,
 VRTeachpointGrid::OnGbwAnalyzeCellMouseClickEvent(// VK_LBUTTON, VK_RBUTTON or VK_MBUTTON only

The second and third lines are definitively swapped because the UINT nChar, line is definitively the method’s parameter declaration. We have no any ideas what can be reason for such funny copy-paste effect. We would like to avoid any misunderstanding while testing your code snippet. Could you please send us a source file with this method to the support mail box at this web site?


Krustys Donuts Aug 15, 2008 - 11:23 AM

Dear Support,


I’ve tried the above suggestion and cannot achieve the desired selection behavoir. The code below shows my attempt:


At initialization:


SiwModifyStyle( __ESIS_STH_PIXEL |


__EGBS_SUBTRACT_SEL_AREAS |


__ESIS_STV_ITEM |


__EGBS_SFB_FULL_ROWS |


__EGBS_RESIZING_CELLS_OUTER_H |


__EGBS_DYNAMIC_RESIZING |


__EGBS_MULTI_AREA_SELECTION |


__EGBS_NO_HIDE_SELECTION |


__EGBS_GRIDLINES,


0,


 //Enable false);


 


 In the OnGbwAnalyzeCellMouseClickEvent:



bool



VRTeachpointGrid::OnGbwAnalyzeCellMouseClickEvent(// VK_LBUTTON, VK_RBUTTON or VK_MBUTTON only

UINT nRepCnt,


// 0 - button up, 1 - single click, 2 - double click, 3 - post single click & begin editing

UINT nFlags,


// mouse event flags

CPoint point


// mouse pointer in client coordinates

)


{


ASSERT_VALID(


ASSERT( 0 <= nRepCnt && nRepCnt <= 3 );


 


{


 


this );if( nChar == VK_LBUTTON )//If the user is pressing the CTRL key.

 


{


CExtGridHitTestInfo htInfo( point );


HitTest( htInfo,


 


{


FocusSet(CPoint(htInfo.m_nColNo, htInfo.m_nRowNo));


 


}


}


if (CExtPopupMenuWnd::IsKeyPressed( VK_CONTROL ))false, true );if (SelectionGetForCell(htInfo.m_nColNo, htInfo.m_nRowNo))return false;


UINT nChar,

Technical Support Aug 16, 2008 - 1:18 PM

The selection behavior on mouse clicks is implemented in grid’s OnGbwAnalyzeCellMouseClickEvent() virtual method which is overridden in your grid class. We do not see where your method invokes the base class method. The incomplete code in your message does not allow us to find out what may be wrong. Could you reproduce this problem using any of our sample applications with a grid or some small test project?


Technical Support May 13, 2008 - 11:40 AM

The Ctrl key classically adds or toggles the selected state of one row. The Shift key does the same but with a range of rows starting from the previously focused row and up to the new focused row and just the clicked row. The grid controls (including the tree grid) support intersected and non-intersected multi row selection models. If __EGBS_SUBTRACT_SEL_AREAS is applied to a grid window by using the SiwModifyStyle() method, both the Shift and Ctrl keys will be used for selecting new rows and un-selecting already selected rows. If this style is not applied, both keys will only add selected rows. You need some kind of non-standard selection behavior in the tree grid window. You need the intersected selection model with the Shift key and simple additive selection with the Ctrl key. So, your tree grid control should have the __EGBS_SUBTRACT_SEL_AREAS style and you can override the CExtGridBaseWnd::OnGbwAnalyzeCellMouseClickEvent() virtual method. This method should check whether the VK_CONTROL key is pressed using the CExtPopupMenuWnd::IsKeyPressed() static method and whether the clicked grid cell is already selected. The CExtGridBaseWnd::HitTest() and CExtGridBaseWnd::SelectionGetForCell() methods should be used to determine the selected state of the just clicked grid cell. If it’s already selected and clicked with the Ctrl key being pressed, then you should simply move focus to it without changing the selection using the CExtGridBaseWnd::FocusSet() method and do not invoke the parent class method.