Red Hat Bugzilla – Bug 994633
Wrong return value in newtWinMenu (and others)
Last modified: 2013-12-04 11:48:17 EST
Description of problem:
newtWinMenu and some other convenient functions from the windows.c family, return incorrect values in my opinion.
Let's take for example: status = newtWinMenu("List", "test list", 40, 0, 0, 5, list_entries, &selection, "Ok", "Cancel", NULL);
. Displays a list of items with the NEWT_FLAG_RETURNEXIT enabled. That means, if i press enter on a list entry, it immediately returns.
The problem is that it returns with status 0. The comment on newt.h says: "Returns the button number pressed, 0 on F12"
Since both pressing enter on a list entry and pressing F12 (or other exit keys) return 0, now i have no way to differentiate them.
Pressing OK button returns 1, cancel 2 next button 3 etc.
Pressing enter on list entry should return 1 as if OK was pressed.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. Use helper function newtWinMenu to make a list component
2. Press enter to select a list entry
3. Check return value
There needs to be a way to differentiate exiting or pressing enter on a list entry.
I attach a patch with a proposed situation that uses the new newtFormRun interface instead of the obsolete newtRunForm
newtWinEntries() can use the same fix as well.
Created attachment 783991 [details]
Fix return value
This bug appears to have been reported against 'rawhide' during the Fedora 20 development cycle.
Changing version to '20'.
More information and reason for this action is here:
If the application had a different button than "OK" in the first position, returning 1 when the enter key is pressed on an item in the list might not be the correct thing to do.
I don't see an easy way how to fix this without breaking the API. Suggestions are welcome.
I'm closing this bug. Please reopen if you see how this can be fixed without breaking the API.