[~,~,button] = ginput(1); PROBLEM
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
[~,~,button] = ginput(1);
PROBLEM: when pressing right button, the contextual window of windows (with actions like Watch, Order By...) keeps appearing.
How can I solve this problem?
4 comentarios
Respuestas (1)
Yatharth
el 8 de Dic. de 2023
Hi Javier,
I understand that the issue you are encountering is related to the behavior of the contextual window that appears when using the "ginput" function to capture mouse clicks in MATLAB. The contextual window in Windows might interfere with the intended usage of ginput for segmenting muscular contractions in your figure.
I tried reproducing the error and did not face the issue in the 2021b or 2023b release.
Here is an alternative approach to handle mouse clicks for segmenting the muscular contractions. One alternative is to use the "ButtonDownFcn" property of the figure to capture mouse clicks without the interference of the contextual window.
% Predefined data for plotting
data1 = rand(100,1); % Sample data for muscle 1
data2 = rand(100,1); % Sample data for muscle 2
% Create a figure with subplots representing muscles
fig = figure;
subplot(2, 1, 1);
plot(data1);
title('Muscle 1');
subplot(2, 1, 2);
plot(data2);
title('Muscle 2');
% Set the ButtonDownFcn for the figure to capture mouse clicks
set(fig, 'ButtonDownFcn', @handleMouseClick);
function handleMouseClick(src, event)
button = get(gcf, 'SelectionType');
if strcmp(button, 'normal') % Left-click
[x, ~] = ginput(1); % Capture the x-coordinate of the click
% Store the x-coordinate for further processing
disp(['Left-click at x = ', num2str(x)]);
elseif strcmp(button, 'alt') % Right-click
% Handle the right-click action (e.g., skip the current swallow)
disp('Right-click detected');
end
end
If you are comfortable, you can share your code and data here along with the reproduction steps, and I can investigate further. Alternatively, you may choose to reach out to MathWorks for technical support.. https://www.mathworks.com/support/contact_us.html
I hope this helps!
0 comentarios
Ver también
Categorías
Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!