Changing the state of a GXCheckBox with a single click when the control does not have focus?

Article ID: 996
Last updated: 01 Feb, 2008
Article ID: 996
Last updated: 01 Feb, 2008
Revision: 1
Views: 2748
Posted: 23 Nov, 1999
by Dean J.
Updated: 01 Feb, 2008
by Dean J.
Problem


A single click on a GXCheckBox in Grid.J does not check/uncheck the box if the control does not have focus.


Cause


GXCheckBox was not designed for this functionality.


Action


Modify activateCurrentCell(boolean bEnableControl) in the GXCore1.java file by adding the highlighted code:
....beginning of activateCurrentCell()....
// initialize the control.
if (isBaseStyleUsed()) style.loadBaseStyle();
if (bEnableControl) control.onSetGXStyle(style, true);

Rectangle r = calcRectFromRowCol(cell.row, cell.col);
try {
if (control instanceof Component) {
if (((Component)control).getParent()!=this&&!bReadOnlyCell) add((Component)control);
onSetControlBounds(((Component)control), cell.row, cell.col, r);
}

if (control instanceof GXExControl) {
((GXExControl)control).doGetFocus(bEnableControl);
} else {
if (control instanceof Component) {
if (bEnableControl&&!bReadOnlyCell) {
((Component)control).setVisible(true);
((Component)control).setEnabled(true);
} else {
((Component)control).setVisible(false);
((Component)control).setEnabled(false);
}
}

// added for checkbox
if (control instanceof GXCheckBox)
{
if (((GXCheckBox)control).getState() == true)
((GXCheckBox)control).setState(false); //true
else
((GXCheckBox)control).setState(true); //false;

((GXCheckBox)control).repaint();
}
// end of checkbox
} } catch (Exception ex) {} ... rest of method....
This article was:   Helpful | Not helpful
Report an issue
Article ID: 996
Last updated: 01 Feb, 2008
Revision: 1
Views: 2748
Posted: 23 Nov, 1999 by Dean J.
Updated: 01 Feb, 2008 by Dean J.

Others in this category