Path: news.mathworks.com!not-for-mail
From: "matt dash" <n.a@mail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Listbox mousedown problems
Date: Tue, 13 May 2008 15:24:03 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 57
Message-ID: <g0cbqj$fj0$1@fred.mathworks.com>
References: <g09d97$ir0$1@fred.mathworks.com> <g09toa$j63$1@canopus.cc.umanitoba.ca> <g0altk$221$1@fred.mathworks.com> <g0b48v$pu8$1@fred.mathworks.com> <g0b5ef$2k6$1@fred.mathworks.com> <g0bu7i$jkr$1@fred.mathworks.com> <g0c031$c1v$1@fred.mathworks.com> <g0c8fn$hmo$1@fred.mathworks.com>
Reply-To: "matt dash" <n.a@mail.com>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1210692243 15968 172.30.248.37 (13 May 2008 15:24:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 13 May 2008 15:24:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 939004
Xref: news.mathworks.com comp.soft-sys.matlab:468171


Hah, Ok, having completely ignored your first post I feel
obligated to help now. See if this is what you're looking for:

For me this does what I think you want, with the possible
exception that it updates as you type and not when you're
done typing, but maybe that's ok with you. The trick is to
use the callbacks of the editbox, not the list box. 

function ListBoxTest
figure
handles.hListbox = uicontrol('style','listbox',...
    'pos',[20 20 100 100],...
    'String',{'a','b','c'},...
    'backg','w',...
    'Callback',@Listbox_Callback);
handles.hEditText = uicontrol('style','edit',...
    'pos',[20 130 100 20],...
    'String','',...
    'backg','w',...
    'Callback',@EditText_Callback);

guidata(gcf,handles)

jEdit=findjobj(handles.hEditText);
jEdit.KeyTypedCallback=@imtyping;


    function Listbox_Callback(hObject, EventData)
        val = get(handles.hListbox,'Value');
        str = get(handles.hListbox,'String');
        set(handles.hEditText,'String',str{val})
    end

    function EditText_Callback(hObject, EventData)
        val = get(handles.hListbox,'Value');
        str = get(handles.hListbox,'String');
        newStr = get(handles.hEditText,'String');
        str{val} = newStr;
        % pause(1)
        set(handles.hListbox,'String',str)
    end

    function imtyping(src,eventdata)
        jEdit=src;
        string=jEdit.getText;
        handles=guidata(gcf);     
        val = get(handles.hListbox,'Value');
        str = get(handles.hListbox,'String');
        newStr = char(string);
        str{val} = newStr;
        set(handles.hListbox,'String',str);
        drawnow
        
        
    end

    end