lejos.nxt.TextMenu

This is where you talk about the NXJ software itself, installation issues, and programming talk.

Moderators: 99jonathan, roger, imaqine

lejos.nxt.TextMenu

Postby clhunter » Mon Jan 28, 2008 2:28 am

Wanted to post a few suggestions for new revisions of lejos. The TextMenu needs some added features.

1. Add a Get Items Method - to retrieve a list of what is currently in the menu. This would help if you need to pass the object to a child child class.

2. The display Method - one of the first things I would add here is a LCD clear. If it is not there then the display function will only overwrite what is needed on the LCD screen. Example if a TextMenu object is passed to a child class and the child class then updates the list of items, if the main menu contains more items than the items you wish to replace it will still show the remaining main menu items on the screen (though not selectable). For now I have just copied and modified the src code and made it part of my project.

I have not picked through all of it to see if there are other ways to improve it but these are two features that would be nice. I am not a programmer by day so if the descriptions are not clear let me know.
Where there is code there is code
clhunter
New User
 
Posts: 3
Joined: Mon Jan 28, 2008 2:12 am
Location: IOWA

Additional Notes

Postby clhunter » Mon Jan 28, 2008 4:58 am

In the constructor
Code: Select all
public TextMnu(String[] items, int topRow, String title)
it would be better to use the setTitle method than to do a direct assignment to the _title variable as setting the title changes other variables in that method.

also in the display function the I would recommend the following change
Code: Select all
if(_title.length() > 0)LCD.drawString(_title,0,_topRow - 1);

as the title was not displaying correctly because null comparrison using either == or .equals() does not function correctly.

So far the changes I have outlined in the two posts seem to fix the problems that I have encountered with the class.
Where there is code there is code
clhunter
New User
 
Posts: 3
Joined: Mon Jan 28, 2008 2:12 am
Location: IOWA

Postby roger » Mon Jan 28, 2008 8:22 pm

Hi clhuter,
Thanks for your suggestions for improving TextMenu. They will be included in the next release.
1. Add a Get Items Method - to retrieve a list of what is currently in the menu. This would help if you need to pass the object to a child child class.
OK
2. The display Method - one of the first things I would add here is a LCD clear. If it is not there then the display function will only overwrite what is needed on the LCD screen. Example if a TextMenu object is passed to a child class and the child class then updates the list of items, if the main menu contains more items than the items you wish to replace it will still show the remaining main menu items on the screen (though not selectable).
Good idea. The display method will clear the LCD to the bottom, but not above the menu. For example, the start up menu shows NXT status information in the top line, and it remains there as sub-menus are called.
In the constructor
public TextMnu(String[] items, int topRow, String title)
it would be better to use the setTitle method than to do a direct assignment to the _title variable as setting the title changes other variables in that method.
Another good idea. In the new release, if you use a title but set the top row to 0, the title will display in row 0 and the top row of the list will be row 1.

also in the display function the I would recommend the following change

if(_title.length() > 0)LCD.drawString(_title,0,_topRow - 1);

as the title was not displaying correctly because null comparrison using either == or .equals() does not function correctly.
What trouble were you having? Can you show me the code?
I think the test in the existing code is necessary to prevent a null pointer exception.
Roger
roger
Moderator
 
Posts: 360
Joined: Fri Jun 01, 2007 4:31 am
Location: Berkeley, CA


Return to NXJ Software

Who is online

Users browsing this forum: No registered users and 6 guests

more stuff