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

[~,~,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 commentaires

Rik
Rik le 14 Nov 2023
This looks like the window doesn't really have focus, but Windows is showing you the right click menu of the desktop. Can you think of any reason why that would be the case?
Javier Imaz Higuera
Javier Imaz Higuera le 15 Nov 2023
For contextualice the problem, I want to manually segmentate the muscular contractions that appear in the figure.
The figure opens up. Each subplot is a muscle, and the user would click left on the beginning of the contraction of each muscle and the time information is collected by ginput and stored in a variable (this seems to work just fine). After this is complete, the figure closes and the next swallow appears.
However, if the swallow looks artefacted, like the subplot 1 or 3, the user has to click right. Then, the pop-up of Windows appeares and it keep on top of the figure unless it is used (like clicking in actualize ('Actualizar')).
Rik
Rik le 16 Nov 2023
That doesn't answer my question.
Javier Imaz Higuera
Javier Imaz Higuera le 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?

Connectez-vous pour commenter.

Réponses (1)

Yatharth
Yatharth le 8 Déc 2023

0 votes

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!

Catégories

En savoir plus sur Data Exploration dans Centre d'aide et File Exchange

Produits

Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by