Re: [Plib-users] (cory vs. pui) The attack of setValuator
Brought to you by:
sjbaker
From: Fay J. F Dr C. U. 46 S. <joh...@eg...> - 2008-06-12 20:42:34
|
Hmmm ... unless somebody else steps in, please forward me a copy of the offending code. I've tried putting in your code snippet and the program works just fine for me, so evidently something else is going on. John F. Fay Technical Fellow Jacobs Technology TEAS Group 850-883-1294 -----Original Message----- From: pli...@li... [mailto:pli...@li...] On Behalf Of cory barton Sent: Thursday, June 12, 2008 3:19 PM To: PLIB Users Subject: [Plib-users] (cory vs. pui) The attack of setValuator I found the following in the PUI documentation today: There are many occasions when you'd really like to have the PUI widget directly drive and/or reflect the value of some memory location in the application code. These calls let you do that: void puObject::setValuator ( int *i ) ; void puObject::setValuator ( float *f ) ; void puObject::setValuator ( char *s ) ; Once you make one of these calls, PUI will automatically update the memory location indicated with the current value of the widget whenever it changes - and also update the appearance of the widget to reflect the value stored in that memory location whenever the widget is redrawn. This is often a lot more convenient than using a callback function to register changes in the widget's value. So I tried it out: //global variable float update = 1.0f; //initialize my puInput inside a function //hertz text input hertz_text = new puInput ( curx, cury, curx + PUI_TEXT_WIDTH, cury + PUI_TEXT_HEIGHT ) ; hertz_text->setValuator( &update ); hertz_text->setLabel( "Hertz" ); hertz_text->setLabelPlace( PUPLACE_TOP_CENTERED ); This compiles, and runs. It seems to work correctly as long as I do not remove all of the characters from the puInput box. However if I am trying to change the value, when I am typing in the new value, if the new value ever becomes a non valid float value, then the program crashes. For example if I want to change 1.0 to 2.0 and I delete 1.0 so I can type 2.0, then instant crash. I can change from 1.0 to 2.0 if I type the 2 after the 1, and then erase the 1. Searching the mail archives and googling didn't help, so I am posting here. I suspect either my weak understanding of pointers means that I am passing an incorrect argument to the setValuator function, or maybe the puInput object is writing invalid data to the update variable. Please let me know how to fix this. thanks, Cory ------------------------------------------------------------------------ - Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ plib-users mailing list pli...@li... https://lists.sourceforge.net/lists/listinfo/plib-users |