MATLAB SIMULINK 7 - GRAPHICAL USER INTERFACE Guide de l'utilisateur Page 369

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 759
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 368
Making Multiple GUIs Work Together
.
.
% Update handles structure
guidata(hObject, handles);
The Icon Editor retrieves the initial color from the Color Palette’s GUI data
via its handles structure:
% in Icon E dito r
function col or = getColor(hObject)
handles = guidata(hObject);
colorPalette = handles.colorPalette;
colorPaletteHandles = guidata(c olorPalette);
color = colorPaletteHandles.mSe lectedColor;
Using UserData Property to Share Data
You can use the UserData property of components in your G U IDE GUI to
share data. When you click the m ouse in the icon editing area, y ou select a
tool. You can use every tool in the Tool Palette to modify the ico n you are
editingbyalteringthetools
CData.TheGUIusestheUserData property
of each tool to record the function that you call when a tool is selected and
applied to the icon-editing area. Each too l alters different aspects of the icon
data. Here is an example of how the pencil tool works.
In the
CreateFcn for the pencil tool, add the user data that points to the
function for the pencil tool:
% in toolPalette
function too lPen cil_CreateFcn(hObject, eventdata, handles)
set(hObject,'UserData', struct('Callback', @pencilT ool Callback));
The Tool Palette tracks the currently selected tool in its h andl es structure’s
mCurrentTool field. You can get this structure from other GUIs after you
create the
handles structure of the Tool P alette. Set the currently selected
tool by calling
guidata after you click a button in the Tool Palette:
% in toolPalette
function too lPal ette_SelectionChangeFcn (hObject, ...
eventdata, han dles )
handles.mCurrentTool = hObject;
9-39
Vue de la page 368
1 2 ... 364 365 366 367 368 369 370 371 372 373 374 ... 758 759

Commentaires sur ces manuels

Pas de commentaire