Ecere SDK/eC Forums https://ecere.org/community/ Print view |
|
Clearing a float DataField https://ecere.org/community/viewtopic.php?f=5&t=415 |
Page 1 of 1 |
Author: | shakeshuck [ Tue Jan 05, 2016 9:25 am ] |
Post subject: | Clearing a float DataField |
Happy new year all. Unfortunately I'm back with another query...! I have a DataField in a ListBox with type float. It initially displays with no value (which is how I want it). After a value has been added, however, there does not seem to be a way to accept user input to clear the field again (empty is valid in this case). Typing in a space or using backspace to clear the field are both considered invalid. |
Author: | jerome [ Tue Jan 05, 2016 4:12 pm ] |
Post subject: | Re: Clearing a float DataField |
Happy New Year Shakeshuck! We're always glad to see you back with queries! You're right that there is no built-in way to clear a ListBox data cell after it is set. There is however a method, UnsetData() to do just that. It was suffering from a bug however, for which I just pushed a fix: https://github.com/ecere/ecere-sdk/comm ... ef5fc94190 You can then write your own code to add a way to clear a data cell, here is one example of mapping Ctrl-Q to do so: Code: Select all
https://github.com/ecere/ecere-sdk/blob ... gs.ec#L305 Hope this helps. -Jerome |
Author: | shakeshuck [ Tue Jan 05, 2016 6:06 pm ] |
Post subject: | Re: Clearing a float DataField |
Hi Jerome, Instead of getting the user to do something "extra", I thought I'd see what happens during editing, so I set NotifyEdited on the ListBox to see what it showed. NotifyEdited gets called as soon as a number is hit, but trying to read the input using Code: Select all
|
Author: | shakeshuck [ Thu Jan 07, 2016 1:16 pm ] |
Post subject: | Re: Clearing a float DataField |
After poking around a bit more, it seems the segfault was caused by casting the GetData request to float (the DataField was float). Using String instead does not cause a failure, but the contents of the String are always either null or empty, regardless of what was entered in the field. |
Author: | jerome [ Thu Jan 07, 2016 11:06 pm ] |
Post subject: | Re: Clearing a float DataField |
Hi Shakeshuck, Sorry for the late reply. The data internally is stored as a float when using a float data type. However the ListBox doesn't really provide a proper public API to query unset cells. In fact, assigning the result of a GetData() to a float will crash on a cell with an unset float value. Something which does happen to work at the moment however is the following: Code: Select all
This will not help address the fact that the user would still need to specifically 'clear' the cell, as there is still no built-in mechanism to 'unset' the value. If the user deletes the whole contents of the edit box and try to save, it will leave the previous value in the ListBox cell. We certainly need to improve on the usability of unset data cells. Regards, -Jerome |
All times are UTC-05:00 | Page 1 of 1 |
Powered by phpBB® Forum Software © phpBB Limited |