필터 지우기
필터 지우기

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

조회 수: 1 (최근 30일)
Javier Imaz Higuera
Javier Imaz Higuera 2023년 11월 14일
답변: Yatharth 2023년 12월 8일
[~,~,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
Rik
Rik 2023년 11월 16일
That doesn't answer my question.
Javier Imaz Higuera
Javier Imaz Higuera 2023년 11월 16일
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?

댓글을 달려면 로그인하십시오.

답변 (1개)

Yatharth
Yatharth 2023년 12월 8일
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!

카테고리

Help CenterFile Exchange에서 Graphics Object Programming에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by