[Plib-users] puLargeInput wrappable text fix.
Brought to you by:
sjbaker
From: sickz6sickz <sic...@ho...> - 2003-04-28 19:50:04
|
Hi all, I've made a fix for what I think is a bug in the puLargeInput class. I stumbled across this when I was using a large input with wrappable text. Sometimes when at the beginning of an empty input if the user tried to go left (left arrow) then it would crash my application out. There wasn't anything to catch if it was wrappable in one section of the code. Im using puLargeInput.cxx,v 1.46. In the checkKey method, within the key switch statement I amended as follows: case PU_KEY_LEFT : case PU_KEY_RIGHT : if ( key == PU_KEY_LEFT ) { //If bottem slider code done by DM. This stops it crashing out sometimes when wrappable text is used. //there is no bottem scrollbar with wrapped text and this would make the app die when the user left //cursored before the start of the 1st line. This is fixed. cursor_position-- ; /* Left key pressed */ if ( bottom_slider ) { if (old_text [ cursor_position ] == '\n') bottom_slider->setValue( ( (prev_line_width - box_width)<0 ) ? 0.0f : float(prev_line_width+10) /max_width); /* If the cursor is going off the left edge of the box, scroll left. */ else if ((bottom_value*max_width) > line_width_to_cursor+5) { bottom_slider->setValue( ((bottom_value*max_width)-(box_width/2)-5)<0 ? 0.0f : ((bottom_value*max_width)-(box_width/2)-5)/max_width ) ; } } } else { cursor_position++ ; /* Right key pressed */ if ( bottom_slider ) { if (old_text [ cursor_position-1 ] == '\n') bottom_slider->setValue(0.0f) ; else if ((bottom_value*max_width)+(box_width) < line_width_to_cursor+5) { bottom_slider->setValue( ((bottom_value*max_width)+(box_width/2)+5)/max_width ) ; } } } select_start_position = select_end_position = cursor_position ; break ; Hope I helped -simon |