sorry for a silly question but I trying to dev a gui app with fltk library in freebasic - how do I make the fl_text_editor widget auto scroll down to the end of the last text - I've been searching on the documentation and manuals and in the forum and just couldn't wrap my brain on that...
here is the code I have so far:
Code: Select all
#INCLUDE "fltk-c.bi"
'Window and widgets:
DIM SHARED AS Fl_Window PTR Window_Main
DIM SHARED AS Fl_Input PTR Input_text
DIM SHARED AS Fl_Text_Editor PTR Editor_text
DIM SHARED AS Fl_Text_Buffer PTR Buffer_text
'dim shared as Fl_Text_Display ptr pTextDisplay
DIM SHARED AS Fl_Button PTR Button_Copy
SUB Create_Window_Main ()
'Window with widgets:
Window_Main = Fl_WindowNew (800, 600, "test gui")
Input_text = Fl_InputNew (100 ,580 ,580, 20, "Text Input")
Editor_text = Fl_Text_EditorNew (10, 10, 500, 500)
Button_Copy = Fl_Return_ButtonNew (700, 580, 100, 20, "Copy")
Fl_Input_SetValue (Input_text, "Edit me!")
'Text editor with an editable text:
Buffer_text = Fl_Text_BufferNew ()
Fl_Text_DisplaySetBuffer (Editor_text, Buffer_text)
Fl_Text_BufferSetText (Buffer_text, "Always look at the right side of life! Be happy, don't worry!")
END SUB
'
SUB Button_Copy_Event CDECL (widget AS FL_Widget PTR)
'Callback function for Button
DIM text AS STRING
text = *Fl_Input_GetValue (Input_text)
Fl_Text_BufferAppend (buffer_text, !"\n" & text & !"\n")
text = ""
END SUB
'Main program:
Create_Window_Main ()
'Fl_WidgetSetCallback0 (Button_Copy, @Button_Copy_Event())
Fl_WidgetSetCallback0 (Button_Copy, @Button_Copy_Event)
Fl_WindowShow (Window_Main)
Fl_Run
END