gtkocamllablgtk

How to get text value from GText.view?


I am creating a GUI in OCaml using Lablgtk. I have created a text view like so:

let textView = GText.view ~border_width:2
            ~packing:vbox#add () in
            textView#buffer#set_text "Hello World";

Later I want to take the text in the text view and pass it to a function. However I can't figure out how to do this and documentation seems to be very scarce. How can I do this? Better yet, is there a tutorial or any thorough documentation for the various objects and their properties available in Lablgtk?


Solution

  • After some research, I found that GText.buffer has a get_text method which can be used like so:

    let text = textView#buffer#get_text () in