Bug 994633 - Wrong return value in newtWinMenu (and others)
Wrong return value in newtWinMenu (and others)
Product: Fedora
Classification: Fedora
Component: newt (Show other bugs)
Unspecified Linux
unspecified Severity medium
: ---
: ---
Assigned To: Miroslav Lichvar
Fedora Extras Quality Assurance
Depends On:
  Show dependency treegraph
Reported: 2013-08-07 12:27 EDT by bill
Modified: 2013-12-04 11:48 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2013-12-04 11:48:17 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
Fix return value (1.43 KB, patch)
2013-08-07 12:28 EDT, bill
no flags Details | Diff

  None (edit)
Description bill 2013-08-07 12:27:06 EDT
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):

How reproducible:

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 

Actual results:

Expected results:

Additional info:
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.
Comment 1 bill 2013-08-07 12:28:01 EDT
Created attachment 783991 [details]
Fix return value
Comment 2 Fedora End Of Life 2013-09-16 12:26:45 EDT
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:
Comment 3 Miroslav Lichvar 2013-10-17 06:52:49 EDT
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.
Comment 4 Miroslav Lichvar 2013-12-04 11:48:17 EST
I'm closing this bug. Please reopen if you see how this can be fixed without breaking the API.

Note You need to log in before you can comment on or make changes to this bug.