[~,~,button] = ginput(1); PROBLEM

1 view (last 30 days)
Javier Imaz Higuera
Javier Imaz Higuera on 14 Nov 2023
Answered: Yatharth on 8 Dec 2023
[~,~,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 Comments
Rik
Rik on 16 Nov 2023
That doesn't answer my question.
Javier Imaz Higuera
Javier Imaz Higuera on 16 Nov 2023
I don't understand the question then, sorry.
The figure should have focus cause the crossed lines appeared above the image (like the aim of a Call of Duty). Only when I press the right button the windows command pop-up appears. However, if I click left, the point is selected and the program works.
I don´t know if that answer your question... Could you rephrase it if not?

Sign in to comment.

Answers (1)

Yatharth
Yatharth on 8 Dec 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!

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!