필터 지우기
필터 지우기

Focus follows mouse in 2015a

조회 수: 2 (최근 30일)
Temu Gautama
Temu Gautama 2015년 9월 4일
댓글: Temu Gautama 2019년 11월 12일
I have recently updated to R2015a on a windows 7 machine. I use focus-follows-mouse (you can change this in the registry), but it my Matlab window is one of the few windows where a mouse-click is necessary to make it the active window to type in. Has anyone experienced the same behaviour and is this by design?
  댓글 수: 4
Temu Gautama
Temu Gautama 2019년 11월 12일
I have found a workaround which yields acceptable results. I get automatic focus, but the matlab command window is also auto-raised. In any case, here's what I did:
I call this function from my startup.m to create a callback for the command window
function focus()
mde = com.mathworks.mde.desk.MLDesktop.getInstance;
cw = mde.getClient( 'Command Window' );
xCmdWndView = cw.getComponent(0).getViewport.getComponent(0);
h_cw = handle( xCmdWndView, 'CallbackProperties' );
commName = 'matlabFocus.exe';
dir1 = 'c:\SomePlace\';
comm1 = fullfile( dir1, commName );
function callMe( varargin )
dosFast( ['"' comm1 '" &'] );
end
set( h_cw, 'MouseEnteredCallback', @callMe );
end
This matlabFocus.exe I created using a tool called AutoIt. The code looks for the matlab window, activates it and sends ctrl-0 to switch to the command window.
Local $hWnd = WinGetHandle( "[REGEXPTITLE:MATLAB [7R]*]" );
If @error Then
MsgBox( $MB_SYSTEMMODAL, "", "An error occurred when trying to retrieve the window handle of Matlab" )
Exit
EndIf
; Set focus of the matlab window
WinActivate( $hWnd ) ; This works
Send( "^0" ) ; Switch to command window
It's a bit of a clumsy work-around, but, hey, it works.
hth,
Temu
Temu Gautama
Temu Gautama 2019년 11월 12일
I forgot the function dosFast:
function dosFast( cmd1 )
hRuntime = java.lang.Runtime.getRuntime();
process = hRuntime.exec( cmd1 );
% status = process.waitFor();
end
(can be put in the focus() function before the callMe() definition)

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by