User`s guide
9 Managing and Sh aring Application Data in GUIDE
guidata(hObject, handles);
When you select the pencil tool and click in the icon-editing area, the Icon
Editor calls the pencil too l function:
% in iconEditor
function ico nEdi tor_WindowButtonDownFcn (hObject,...
eventdata, ha ndle s)
toolPalette = handles.toolPalette;
toolPaletteHandles = guidata(to olPalette);
.
.
.
userData = get(toolPaletteHandl es.mCurrentTool, 'UserData');
handles.mIconCData = userData.C allback(toolPaletteHand les, ...
toolPaletteHandles.mCurrentTool, handles.mIconCData, ...);
The following code shows how the pixel value in the icon-editing area under
the mouse click (the Tool icon’s
CData) changes to the color currently selected
in the Color Palette:
% in toolPalette
function cda ta = pencilToolCallback(handles, toolstruct, cdata,...)
iconEditor = handles.iconEditor;
iconEditorHandles = guidata(ico nEditor);
x = ...
y = ...
% update color of the selected block
color = iconEditorHandles.getCo lor(iconEditor);
cdata(y, x,: ) = color;
Displaying the Current Tool’s Cursor
You can have the cursor display the current tools pointer icon when the
mouse is in the editing area and the default arrow displays outside the
editing area. To do this yo u m u s t identify the selected too l th ro ugh the Tool
Palette’s
handles structure:
% in Icon E dito r
function ico nEdi tor_WindowButtonMotionF cn(hObject, ...
eventdata, han dles )
9-40