Effacer les filtres
Effacer les filtres

Focus follows mouse in 2015a

2 vues (au cours des 30 derniers jours)
Temu Gautama
Temu Gautama le 4 Sep 2015
Commenté : Temu Gautama le 12 Nov 2019
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 commentaires
Temu Gautama
Temu Gautama le 12 Nov 2019
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 le 12 Nov 2019
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)

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by