
8 Programming the GUI
8-34
If you click the GUI enough times, the circle disappears entirely.
Programming a User Interface Control to Update an ActiveX Control
This topic continues the previous example by adding a slider to the GUI and
programming the slider to change the circle radius. This example must also
update the slider if the user clicks on the circle.
1 Add a slider to your layout and then add the following code to the slider1
Callback callback:
handles.activex1.radius = ...
get(hObject,'Value')*handles.default_radius;
handles.activex1.label = ...
['Radius = ' num2str(handles.activex1.radius)];
refresh(handles.figure1);
The first command
- Gets the
Value of the slider, which in this example is a number between 0
and 1, the default values of the slider’s
Min and Max properties.
- Sets
handles.activex1.radius equal to the Value times the default
radius.
2 In the opening function, add the default radius to the handles structure. The
activex1_Click callback uses the default radius to update the slider value
if the user clicks the circle.
Commentaires sur ces manuels