|
|
Introduction
Why use a framework?
Tutorial
Class tree
Open protocols
Download
GitHub
Vision
API stability
Code optimization
Bibliography
Features
Object messaging
Extensibility
Drag-and-Drop
Networking
3D Graphics
Powerful tables
Styled text editor
Memory leak debugger
Known bugs
Future plans
Projects
FAQ
Donate
Other software
What's new!
Log in
|
|
|
|
Table suite
The JX Application Framework provides a powerful suite of classes for displaying 2D tables (e.g. spreadsheets or board games) that uses the Model-View-Controller paradigm. Derived classes of JTableData store the data, and JTable automatically insures that the display is kept up to date. JTable even includes support for editing the contents of each cell within the table itself.
The row and column headers are separate widgets with the ability to allow the user to resize the columns by dragging.
Rules for selecting cells
There are many different ways that cells can be selected in a table. Some tables will only allow a single cell to be selected at one time. Others will allow multiple cells to be selected, but only contiguously. (Some may restrict this to stay within a single row or column.) The most flexible ones will allow discontiguous selection, where any cell can be selected at any time. Because of this infinite variety, JTable simply stores a JTableSelection object. It is up to you to decide how to use it. (JXTable does provide utility functions for automatically handling the standard cases, however.)
When a table allows multiple cells to be selected, it should also provide a way to extend the selection. This is done via a selection anchor. The anchor is the cell from which the selection extends and shrinks as the user drags the mouse. The cell containing the mouse is, for levity, called the boat cell.
If the user releases the mouse and begins another extend-drag elsewhere, it should produce the same result as if he had continued the original drag, so the boat and anchor cells must both be saved. This is also necessary in order to allow the user to extend the selection further via the arrow keys. JTableSelection can store the boat and anchor cells and update them as rows and columns are inserted, moved, and removed.
While dragging to select an area, previously selected cells should stay selected, even if the user extends the area to cover them and then shrinks the area back to expose them again. JTableSelection can do this for you automatically, too, via ExtendSelection().
|
User's action
|
Program's response
|
|
left-click
|
- Deselect all cells
- Select cell containing the cursor
- If only single selection is allowed, repeat steps 1 and 2 as the user drags the mouse
- If multiple selection is allowed, set boat and anchor cells to cell that was clicked and switch to right-click mode
|
Shift-left-click
right-click
|
(only if multiple selection is allowed)
- Undo selection produced by latest extend-drag
- Set boat cell to cell containing the cursor
- Select area between boat and anchor cells
|
Control-left-click
on selected cell
|
(only if single cell or discontiguous selection is allowed)
- Deselect cell
- Clear boat and anchor cells
- As the user drags the mouse, deselect all cells encountered
|
Control-left-click
on unselected cell
|
(only if discontiguous selection is allowed)
- Select cell
- As the user drags the mouse, select all cells encountered
- When the user releases the mouse, set boat and anchor cells to last cell encountered
|
arrows
(without selection)
|
(only in 1D list)
- Up arrow selects bottom cell
Down arrow selects top cell
(e.g. this allows user to select second cell by pressing down arrow twice)
- Set boat and anchor cells to newly selected cell
|
|
arrows
(with selection)
|
- Deselect all cells
- Move anchor cell by 1 row/column
- Set boat cell to anchor cell
- Select anchor cell
|
Shift-arrows
(with selection)
|
(only if multiple selection is allowed)
- Undo selection produced by latest extend-drag
- Move boat cell by 1 row/column
- Select area between boat and anchor cells
|
Notes:
- The Shift modifier takes precedence over the Control modifier.
- If Drag-and-Drop is allowed, it should only be initiated if the user left-clicks with no modifiers. If the cell is selected, the current selection is maintained. Otherwise, all cells are deselected, and the clicked cell is selected.
- If edit-in-place is allowed, it sometimes looks nicer if the cell is deselected when editing begins. For convenience, the cell should be reselected when editing ends. You can catch these events in CreateInputField() and ExtractInputData(), respectively.
- If you want right-click to open a context menu instead, then the selection rules for Drag-and-Drop should be used: If the cell is selected, the current selection is maintained. Otherwise, all cells are deselected, and the clicked cell is selected.
|
|