MATLAB SIMULINK 7 - GRAPHICAL USER INTERFACE Instrukcja Użytkownika Strona 236

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 500
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 235
8 Programming a GUIDE UI
8-20
Panel
Make the Panel Respond to Button Clicks
You can create a callback function that executes when the end user right-clicks or left-
clicks on the panel. If you are working in GUIDE, then right-click the panel in the layout
and select View Callbacks > ButtonDownFcn to create the callback function.
This code is an example of a ButtonDownFcn callback in GUIDE.
function uipanel1_ButtonDownFcn(hObject, eventdata, handles)
% hObject handle to uipanel1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
display('Mouse button was pressed');
When the end user clicks on the panel, this function displays the text, 'Mouse button
was pressed', in the Command Window.
Resize the Window and Panel
By default, GUIDE UIs cannot be resized, but you can override this behavior by selecting
Tools > GUI Options and setting Resize behavior to Proportional.
Programmatic UIs can be resized by default, and you can change this behavior by setting
the Resize property of the figure on or off.
When your UI is resizable, the position of components in the window adjust as the user
resizes it. If you have a panel in your UI, then the panel’s size will change with the
window’s size. Use the panel’s SizeChangedFcn callback to make your UI perform specific
tasks when the panel resizes.
This code is an example of a panel’s SizeChangedFcn callback in a GUIDE UI. When the
end user resizes the window, this function modifies the font size of static text inside the
panel.
function uipanel1_SizeChangedFcn(hObject, eventdata, handles)
% hObject handle to uipanel1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(hObject,'Units','Points')
panelSizePts = get(hObject,'Position');
panelHeight = panelSizePts(4);
Przeglądanie stron 235
1 2 ... 231 232 233 234 235 236 237 238 239 240 241 ... 499 500

Komentarze do niniejszej Instrukcji

Brak uwag