Skip to content

Rcmdr Plugin and menus.txt

3 messages · John Fox, Charilaos Skiadas

#
Dear Haris,

I'll take a look at this as soon as I have a chance, probably not until
tomorrow. In the meantime I've attached a "preprint" of an article that
describes how to write plug-ins. Perhaps you'll find that helpful. (I don't
know whether it will go through r-help, but you should receive the direct
email.)

Regards,
 John

--------------------------------
John Fox, Professor
Department of Sociology
McMaster University
Hamilton, Ontario
Canada L8S 4M4
905-525-9140x23604
http://socserv.mcmaster.ca/jfox
--------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: wrapper.pdf
Type: application/pdf
Size: 211442 bytes
Desc: not available
Url : https://stat.ethz.ch/pipermail/r-help/attachments/20071101/3603125e/attachment.pdf
#
Thanks John, no hurry.

I tried to debug it a little bit, without much success. Two things I  
discovered:
1) The exact same lines work just fine if I place them in the Rcmdr- 
menus.txt file in the Rcmdr package (and add the "testOne" function  
also.)
2) While trying to do debug(Commander), the thing I noticed is that,  
when reading items from the menus.txt file, the function seems to  
process them in the opposite order. So it starts from the last item  
and moves up (well, I don't know if it would move up since it crashes  
in the absence of the psychMenu object). It seems the problem might  
be with the line:
Menus <- addMenus(Menus)
When examining Menus, I noticed that my new commands were added at  
the beginning of the Menus data frame, and in a messed up order:

Browse[1]> Menus[1:20,1:3]
      type  menuOrItem operationOrParent
8    item   psychMenu           cascade
1    menu   psychMenu           topMenu
4    menu testTwoMenu         psychMenu
5    item testTwoMenu           command
6    item testTwoMenu           command
7    item testTwoMenu           command
2    item   psychMenu           command
2100 menu    fileMenu           topMenu
3    item    fileMenu           command
410  item    fileMenu           command
510  item    fileMenu           command
610  item    fileMenu           command
710  item    fileMenu           command
810  item    fileMenu           command
9    item    fileMenu           command
10   menu    exitMenu          fileMenu
11   item    exitMenu           command
12   item    exitMenu           command
13   item    fileMenu           cascade
14   item     topMenu           cascade


I would hazard to guess that the problem is with the call "Menus <-  
insertRows(Menus, line, where)"  in line 866 of Rcmdr. But at that  
point things got a bit too "technical" for me. Hope this helps narrow  
the problem down a bit.

Thanks for the preprint. It is nicely written, though it didn't shed  
any light on this problem.

Haris Skiadas
Department of Mathematics and Computer Science
Hanover College
On Nov 1, 2007, at 3:32 PM, John Fox wrote:

            
#
Dear Haris,

First, there's nothing wrong (at least that I can see) with your menu file,
although I would consider using the activation field to determine whether
the menu items should be activated or "grayed out" in the current context.

The problem you encountered is a bug in the Commander() function that,
apparently, didn't surface before because no one previously tried to define
a submenu of a top-level menu introduced by a plug-in package, as opposed to
a new top-level menu or a submenu of one of the standard Rcmdr top-level
menus. Briefly, the expression Menus[, "menuOrItem"] == line[1,
"menuOrItem"], which is meant to determine where the submenu is to be
"cascaded" under its parent menu, should read Menus[, "commandOrMenu"] ==
line[1, "menuOrItem"].

I've now fixed this bug. I intend to upload a new version (1.3-6) of the
Rcmdr package, which addresses several small problems, to CRAN soon,
probably later today.

Thanks for bringing this bug to my attention.

John

--------------------------------
John Fox, Professor
Department of Sociology
McMaster University
Hamilton, Ontario
Canada L8S 4M4
905-525-9140x23604
http://socserv.mcmaster.ca/jfox 
--------------------------------