[Rd] Windows RConsole Focus

James Wettenhall wettenhall at wehi.edu.au
Wed Oct 22 11:16:11 MEST 2003


Hi,

I was looking for a Windows-specific R function to focus the 
console window and couldn't find one.  The motivation is that 
after loading the tcltk package, the "main" Tk window "." is 
presumably focused but then immediately withdrawn (hidden) so 
the RConsole loses its focus and you have to click on it to 
continue typing.

Would there be any interest in including a winConsoleFocus() 
function in R at some stage or is it already there?

I tried implementing a quick solution (below) which seemes 
to work.

Regards,
James

src/gnuwin32/rui.c
------------------
int winconsolefocus()
{
    show(RConsole);
    return 0;
}

src/gnuwin32/rui.h
------------------
int winconsolefocus(void);

src/gnuwin32/extra.c
--------------------
SEXP do_winconsolefocus(SEXP call, SEXP op, SEXP args, SEXP rho)
{
    SEXP ans;
    Rboolean success = TRUE;
    winconsolefocus();
    PROTECT(ans = allocVector(LGLSXP, 1));
    LOGICAL(ans)[0] = success;
    UNPROTECT(1);
    return ans;
}

src/main/names.c
----------------
{"winConsoleFocus",do_winconsolefocus,0,11,     0,      
{PP_FUNCALL, PREC_FN,   0}},

src/include/Internal.h
----------------------
SEXP do_winconsolefocus(SEXP, SEXP, SEXP, SEXP);

src/library/base/R/windows/winDialog.R
---------------------------------------
winConsoleFocus <- function()
    invisible(.Internal(winConsoleFocus()))



More information about the R-devel mailing list