Is it possible to create a scrolling, programmatic GUI containing static text and editable text boxes?

I asked this question earlier, but failed to include all the details.
I’m looking to create a GUI containing a combination of 80 static/editable text boxes. It would look something like this;
Static text Editable Text (1)
Static text Editable Text
Static text Editable Text
Static text Editable Text
Static text Editable Text
Static text Editable Text . . . . . . . . . . . . .
Static text Editable Text (80)
Creating the text boxes is not a problem. But getting the GUI to scroll through all 80 of these combinations is. I’m looking to place a vertical scroll bar on the right side of the GUI and allow the user to scroll down to the applicable line where he/she can input specific values in the editable text box.
Can MATLAB do this? If so, does anyone have a reference as to how to approach this?
Thank you.

7 Commenti

80 Textboxes sounds like a lot... would it be possible to replace them with a uitable?
Arthur, after spending several hours trying to get this to work, I've given your advice a shot. I'm finding out that callbacks are somewhat like alchemy. I've got the following code:
f = figure('Position',[100 100 400 150]);
columnname = {'Default Value'};
columnformat = {'numeric'};
columneditable = [true];
rowname = {'Standard Message Header','Word 1','Word 2','Word 3','Word 4','Word 5','Word 6','Word 7','Word 8','Word 9','Word 10','Word 11','Word 12'};
dat = {' '; 0.12345; 1.2345; 12.345; 21102; 0.12345; 1.2345; 12.345; 21102; 0.12345; 1.2345; 12.345; 21102;};
t = uitable('Units','normalized','Position',... [0.1 0.1 0.9 0.9], 'Data', dat,... 'ColumnName', columnname,... 'ColumnFormat', columnformat,... 'ColumnEditable', columneditable,... 'RowName',rowname,... 'CellEditCallBack',@ValueChange_Callback);
function ValueChange_Callback(varargin)
if (e.Indices(1) == 2 && ...
(e.NewData < 0 || e.NewData > 120))
tableData = get(o, 'data');
tableData{e.Indices(1)} = e.PreviousData;
set(o, 'data', tableData);
error('Value must be between 0 and 100.');
end
end
set(t, 'CellEditCallback', @ValueVerificationCallback);
I modeled this after an example on the mathworks WEB site just to see if it would execute. It works up to the point where I would expect the first data value to update if I changed it and hit return. MATLAB is throwing an error stating "Function definitions are not permitted in this context".
Any ideas as to why this is happening?
Is your m-file a function or a script? You can only declare a new function if your m-file is a function itself.
Arthur, good catch. I just noticed this!!
So I could have a function followed by another function or somehow throw all of this into an M-file script. I'm leaning towards an M-fil script so i can see the values in dat update in the workspace. But if I go this route, does the manner in which I utilize the cell edit callback change?
If you use a script, your cellEditCallback HAS to be in a separate (function) file. Otherwise you can't declare it.

Accedi per commentare.

 Risposta accettata

Yes. Put all of the uicontrol into one uipanel. Put a scrollbar outside of the panel. Have the scrollbar callback change the Position of the uipanel. Make sure that Clipping is enabled on the uipanel.
Usually the trick works better if you use two uipanel, one acting as a "frame" in the figure, and the other moving within the first. Clipping on the outer uipanel ensures that only the parts of the second panel that are within the visible frame get shown.

Più risposte (0)

Categorie

Scopri di più su App Building in Centro assistenza e File Exchange

Prodotti

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by