how to create a drawing callback ?
1 view (last 30 days)
Hi, Im used to working in C and opengl and i am trying to maintain the same workflow. I wrote the code attached at the bottom (basically what it does is open a figure and an axis and allow to draw markers in different colors according to the mouse key that was pressed.
however this is not the proper way to do this (in C that is). I used to define a drawing callback function - all plotting/drawing is done in it. the input callback simply change the global variables. The problem is when i tried to build this type of function i couldnt find a way to execute it (since its supposed to be executed after any event and not a specific one)
anyone has a clue how to set a custom drawing callback? I hope i was clear (i know the phrasing came out bad ) Thanks
function [ ] = main5( )
%main5 demonstrates how to process keybord and mouse inputs
%clear all; close all; clc; %not recommended use inside functions
'Position',[200 200 width height],'Color',bgcolor); %bg is set to red so we know that we can only see the axes
Axesh=axes('Color','c','Position',[0 0 1 1],...
'XLim',[0 width],'YLim',[0 height],'XTick',,'YTick',);
daspect([1 1 1]);
function [ ] = KeyboardCB(hObject,event)
%Example print of the key which was pressed
fprintf('I pressed %c key\n',event.Key);
function [ ] = MouseDownCB(hObject,event)
%Example print X,Y coordinates when mouse is clicked
disp(['You clicked X:',num2str(CursorPos(1)),', Y:',num2str(CursorPos(2))]);