As somebody already posted a patch to get the Cells properly under ones cursor, my Patch now takes as well into account, that some cells might be fixed.
What it does NOT is an accurate Width-positioning from the drawn cells. This is due to lack of a method in the Cell-Render which retrieves the width drawn instead of the of the width from the the Model. (There is an additional offset in the Border.)
Despite this inaccuracy, the following change will give you the Cell for the given Coordinates.
/**
* Corrects the behaviour, if some columns are fixed and therefore invisible
*/
@Override
public Point getCellForCoordinates(int x, int y) {
Point cell = super.getCellForCoordinates(x, y);
if (cell.x < getFixedColumnCount()) {
return getValidCell(cell.x, cell.y);
} else {
int width = 0;
for (int i = m_LeftColumn; width < x; i++) {
if (i >= m_Model.getColumnCount())
return new Point(-1, -1);
width += getColumnWidth(i - m_Model.getFixedSelectableColumnCount());
if (x < width)
cell.x = i;
}
return getValidCell(cell.x - m_Model.getFixedSelectableColumnCount(),
cell.y);
}
}
Logged In: YES
user_id=703323
Originator: YES
The above patch is unfortunately NOT correct :( (Did not cover all situations.)
Retesting and changing to work brings the following code:
********
public Point getCellForCoordinates(int x, int y) {
Point cell = super.getCellForCoordinates(x, y);
if (cell.x < getFixedColumnCount()) {
return getValidCell(cell.x, cell.y);
} else {
int width = 0;
/* count the width for the fixed cells */
for (int i = 0; width < x && i<= m_Model.getFixedSelectableColumnCount(); i++) {
if (i >= m_Model.getColumnCount())
return new Point(-1, -1);
width += getColumnWidth(i);
if (x < width)
cell.x = i;
}
/* count the width for the non-fixed cells */
for (int i = m_LeftColumn; width < x; i++) {
if (i >= m_Model.getColumnCount())
return new Point(-1, -1);
width += getColumnWidth(i);
if (x < width)
cell.x = i;
}
return getValidCell(cell.x,
cell.y);
}
}
************
Note:
Point cell = super.getCellForCoordinates(x, y);
is required to have the cell.y set, which is done in the Table with getRowForY(y); which is private. Which make the patching either by subclassing your own KTable OR replace the Method.
BTW: Now it works correct, without any problems about the Borders.