Code covered by the BSD License  

Highlights from
editable table

3.0

3.0 | 1 rating Rate this file 8 Downloads (last 30 days) File Size: 4.08 KB File ID: #7026
image thumbnail

editable table

by Peter Graat

 

01 Mar 2005 (Updated 02 Mar 2005)

Example of an editable table with control over which characters are valid

| Watch this File

File Information
Description

CREATABLE.M, WINDOWCLICK.M, EDITABLE.M

This is an example to show how an editable table can be created without using MATLAB's edit uicontrol. It has the advantage that you have more control over how key presses and mouse clicks are handled. You can limit the user input to certain characters, control the behaviour of arrow keys, etc..

In this example a table with numeric values is created in the current axis using CREATABLE.M. CREATABLE(NR,NC) creates a table with NR rows and NC columns filled with zeros. CREATABLE(DATA) creates a table with the same size as the DATA matrix and filled with the values of DATA.

WINDOWCLICK.M handles mouse button clicks inside the table (to start editing) and outside the table (to stop editing). It is also called by certain key presses that have the same effect as a mouse button click (arrow keys, enter, escape).

EDITABLE.M handles keyboard presses. Once a certain table cell has been clicked, any valid numeric character (including '+', '-', '.' and 'e') can be typed.

Furthermore, 'delete' empties the cell contents, 'backspace' removes the right-most character, 'arrow keys' move to another cell, 'enter' reselects the current cell, 'escape' (or clicking with the mouse outside the table) stops editing. The DATA is stored in the userdata of the current axes, thus at any time
during or after editing: DATA = GET(GCA,'USERDATA'). If a table cell contains an invalid number, NaN is returned for that cell.

These functions do not form a ready-to-use uicontrol. They are meant to be adapted for your own needs. Therefore, the functions have been kept as short as possible and no error checking (e.g. on typing beyond the cell width) is performed. The functions have been developed with MATLAB 7.0 (R14) and have also been tested with MATLAB 6.1 (R12).

MATLAB release MATLAB 7 (R14)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (2)
03 Mar 2005 Jos x@y.z

Also see OPENVAR

31 Mar 2005 S I

In general, it works well.

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
gui tools Peter Graat 22 Oct 2008 07:42:23
example Peter Graat 22 Oct 2008 07:42:23
editable Peter Graat 22 Oct 2008 07:42:23
table Peter Graat 22 Oct 2008 07:42:23
character Peter Graat 22 Oct 2008 07:42:23
key Peter Graat 22 Oct 2008 07:42:23

Contact us at files@mathworks.com