%% textbox_callback
%    callback for when the text of a callback is changed.
% inputs:
%   object - current GUI object
%   src - source of the callback calling
%   event - event that triggered the callback
% outputs:
%   none
% Author: Colin Eles elesc@mcmaster.ca
% Organization: McMaster Centre for Software Certification
function [] = textbox_callback(object,src,event)
% make sure the character pressed isn't empty

if((strcmp(event.Character,'z')) && (strcmp(char(event.Modifier),'command') || strcmp(char(event.Modifier),'control')))
    return
end
if((strcmp(event.Character,'r')) && (strcmp(char(event.Modifier),'command') || strcmp(char(event.Modifier),'control')))
    return
end

if strcmp(event.Key,'tab')
    event.Character = '';
    return;
end


if(~isempty(unicode2native(event.Character)))
    % make sure the character is a printable character
    if event.Character > 33 || event.Character == 8
        if object.pvs_checked == 1
            object.pvs_checked = 0;
            object.update_Statusbar;
            if (object.mode == 1)
                TableBlock.set_block_display(object.block_handle,object.pvs_checked);
            end
        end
    end
    
    % hack because api does not update the string field of
    % textbox until after it loses focus. temporarily focus on
    % label, read string, refocus on textbox.
    uicontrol(object.name_label);
        
    undo_data.action = 1;
    undo_data.grid = [];
    undo_data.cell = src;
    undo_data.text = get(src,'String');
    undo_data.subgrid = [];
    
    object.undo_man.new_state(undo_data);

    uicontrol(src);
    figure(object.fig);

    object.update_undoredo;
    
    
    
end