Clear Filters
Clear Filters

Error displaying custom Data Tips

21 views (last 30 days)
Veronica Taurino
Veronica Taurino on 16 Mar 2021
Edited: Veronica Taurino on 23 Mar 2021
I've created a callback to displaying Data Tips on a pointcloud (pcshow) after the space bar is pressed. The flow is:
  • Press on the space bar
  • click on a point
  • custom data tips appear
At first, the DataTip shows an error message, but if I click on the data tip or in general over the figure, the correct data tip appears and the error message does not show again. How can I avoid the appearence of that message? Where should I look for the problem?
Error message: unable to update data tip using custom update function.
Thank you.
Veronica Taurino
Veronica Taurino on 19 Mar 2021
Edited: Veronica Taurino on 23 Mar 2021
Thank you for your reply. It's not (yet) a neat and efficent code, don't judge me please ahah
I create a tab panel with 3 figures (pcshow function, they are point clouds). When the user clicks the space bar on a figure, 3d rotation mode has to quit and the ''datatip'' mode starts, so that when the user clicks on a point over the point clouds, datatips are added to the figure. Then, when the user pushes the space bar again, the datatips are hidden and 3D rotation mode starts again.
Please note that to allow the callback during the 3D rotation mode, I used this undocumented Matlab code:
function [hTabGroup] = PlotInTab(path_pc)
ptCloud = plyread(path_pc);
struct_data={'1','2','3';, ptCloud.vertex.two , ptCloud.vertex.three};
hTabGroup = uitabgroup;
% Plot
for iFig = 1:3
tab = uitab(hTabGroup, 'title',struct_data{1,iFig});
a = axes('parent', tab_all{iFig});
pc(iFig)=pcshow([ptCloud.vertex.x ptCloud.vertex.y ptCloud.vertex.z], struct_data{2,iFig},'Parent',axes_all{iFig});
%[...Stuff - custom colorbar, colormap, colorbar tick...]
hManager = uigetmodemanager(hFig);
set(hManager.WindowListenerHandles, 'Enable', 'off'); % HG1
[hManager.WindowListenerHandles.Enabled] = deal(false); % HG2
set(hFig, 'WindowKeyPressFcn', []);
set(hFig, 'KeyPressFcn', @isspace); % callback 2
set(gcf, 'MenuBar', 'none');
set(gcf, 'ToolBar', 'none');
axis 'equal'
axis 'tight'
axis 'off'
% Global variables - callback
%% 1. Callback: Display DataTips %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function txt = displayCoordinates(hObject,info)
% Add Value row to the datatips:
%% 2. Callback: When space bar is pushed, starts "datatips" mode %%%%%%%%%%%%%%%%%%
function isspace(hObject,~)
% check state space bar button: 0 - show datatips, 1: hide datatips
if check_state==0 % If global variable is 0, shows DataTips
dcm = datacursormode;
dcm.Enable = 'on';
dcm.UpdateFcn = @displayCoordinates; % per le coordinate
if isempty(hObject.Children(end).SelectedTab.Children(end).Children.Children)
waitforbuttonpress(); %to avoid errors ?
hObject.Children(end).SelectedTab.Children(end).Children.Children.Visible='on' ;
pause(0.01); drawnow;
else % If global variable is 1, hide DataTips
dcm = datacursormode;
dcm.Enable = 'off';
hObject.Children(end).SelectedTab.Children(end).Children.Children.Visible='off' ;
rotate3d on
pause(0.01); drawnow;
hManager = uigetmodemanager(hFig);
set(hManager.WindowListenerHandles, 'Enable', 'off'); % HG1
[hManager.WindowListenerHandles.Enabled] = deal(false); % HG2
set(hFig, 'WindowKeyPressFcn', []);
set(hFig, 'KeyPressFcn', @isspace);
Asvin Kumar
Asvin Kumar on 22 Mar 2021
Hey, this is going to be hard to debug. I'm out of bandwidth at the moment and won't be able to look into it immediately.
A few suggestions to make it easier for others in the community:
  1. Provide a way to reproduce the behaviour. Maybe provide some code which people can quickly execute and start tinkering with.
  2. Or, if possible, come up with a short demo of your problem by just using scatter plot like in this example.
  3. Provide more details on waitforbuttonpress() because it seems like you've added that to work around your problem. What does it do? Does it work?

Sign in to comment.

Answers (0)


Find more on Graphics Performance in Help Center and File Exchange


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!