function p.on_start(wid)
    local min_x = 0.1
    local max_x = 0.9
    local min_y = 0.3
    local max_y = 0.86
    local char_w = 0.02
    local char_h = 0.04
    local col = std.vec(0.0, 0.5, 0.5)
    local init_str = ga_get_s("temp.game.note.text")
    ga_win_widget_mutable_text_box_start(wid, 
        min_x, max_x, min_y, max_y, char_w, char_h,
        col, init_str)
end

function p.on_end(wid)
    p.refresh_block(wid)
    ga_win_widget_mutable_text_box_end(wid) --Important.
end

function p.refresh_block(wid)
    local txt = ga_win_widget_mutable_text_box_get_text(wid)
    local level = ga_get_i("temp.game.note.ent.level")
    local bp = std.bp(0,0,0)
    bp.x = ga_get_i("temp.game.note.ent.bp.x")
    bp.y = ga_get_i("temp.game.note.ent.bp.y")
    bp.z = ga_get_i("temp.game.note.ent.bp.z")
    ga_block_set_s(level, bp, "txt", txt)
end

function p.process_input(wid)
    if ga_win_key_pressed(wid, "ESC") then
        ga_window_pop()
    end

    --This function is just showing how to
    --use functions to get input.
    --Note that the "mutable text box widget"
    --is handled automatically by the engine.

    --Also, we are showing how to use the functions
    --to read and write text from the windows clipboard.

    if  ga_win_mouse_pressed(wid, true) then
        local str = ga_win_widget_mutable_text_box_get_text(wid)
        ga_copy_to_clipboard(str)
    end

    --ga_win_mouse_pressed also works.
    if  ga_win_mouse_pressed(wid, false) then
        local str = ga_paste_from_clipboard()
        ga_win_widget_mutable_text_box_set_text(wid, str)
    end

    --Notice that there also the functions
    --ga_win_mouse_down,
    --ga_win_key_down,
    --ga_win_key_pressed.
end

function p.render(wid)
    --The mutable_text_box widget is rendered automatically
    --(because it was created).

    ga_win_set_background(wid, std.vec(0.0, 0.0, 0.0), 0.95)

    ga_win_set_char_size(wid, 0.02, 0.04)
    ga_win_txt_center(wid, 0.94, "THIS IS A NOTE")
    ga_win_txt_center(wid, 0.14, "Left Click To Copy Message To Clipboard")
    ga_win_txt_center(wid, 0.08, "Right Click To Paste Message From Clipboard")
    ga_win_txt_center(wid, 0.02, "Go Back (ESC)")
end
