Changeset 224 for trunk/src


Ignore:
Timestamp:
Nov 9, 2009, 3:56:17 PM (16 years ago)
Author:
lpino
Message:
  • Fix getText method. Was returning previous selected item
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/plugins/org.eclipse.swt/Eclipse SWT/pm/org/eclipse/swt/widgets/Combo.java

    r206 r224  
    430430        if (length != OS.LIT_ERROR) {
    431431                PSZ buffer = new PSZ(length+1);
    432                 int result = OS.WinSendMsg (handle, OS.LM_QUERYITEMTEXT, OS.MPFROM2SHORT((short)length,(short)index), buffer);
     432                int result = OS.WinSendMsg (handle, OS.LM_QUERYITEMTEXT, OS.MPFROM2SHORT((short)index,(short)length), buffer);
    433433                if (result != 0) return buffer.toString ();
    434434        }
     
    579579public String getText () {
    580580        checkWidget ();
    581         int length = OS.WinQueryWindowTextLength (handle);
     581        int index = OS.WinSendMsg (handle, OS.LM_QUERYSELECTION, (short)OS.LIT_CURSOR, 0);
     582        int length = OS.WinSendMsg (handle, OS.LM_QUERYITEMTEXTLENGTH, (short)index, 0);
    582583        if (length == 0) return "";
    583584        PSZ buffer = new PSZ(length);
    584         OS.WinQueryWindowText (handle, length + 1, buffer);
     585        OS.WinSendMsg (handle, OS.LM_QUERYITEMTEXT, OS.MPFROM2SHORT((short)index,(short)length), buffer);
    585586        return buffer.toString ();
    586587}
     
    709710        }
    710711
    711 //      /* Use LM_SEARCHSTRING to search for the item */
     712        /* Use LM_SEARCHSTRING to search for the item */
    712713        int count = OS.WinSendMsg (handle, OS.LM_QUERYITEMCOUNT, 0, 0);
    713714        if (!((0 <= start) && (start < count))) return -1;
    714         int index = 0;
     715        int index = start - 1;
    715716        PSZ buffer = new PSZ(string);
    716         index = OS.WinSendMsg (handle, OS.LM_SEARCHSTRING, OS.MPFROM2SHORT((short)OS.LSS_CASESENSITIVE,(short)(start)), buffer);
     717        index = OS.WinSendMsg (handle, OS.LM_SEARCHSTRING, OS.MPFROM2SHORT((short)OS.LSS_CASESENSITIVE,(short)(index)), buffer);
    717718        if (index == OS.LIT_ERROR || index < start) return -1;
    718719        return index;
     
    811812                        if (length == OS.LIT_ERROR) break;
    812813                        buffer = new PSZ (length + 1);
    813                         int result = OS.WinSendMsg (handle, OS.LM_QUERYITEMTEXT, OS.MPFROM2SHORT((short)length,(short)start), buffer);
     814                        int result = OS.WinSendMsg (handle, OS.LM_QUERYITEMTEXT, OS.MPFROM2SHORT((short)start,(short)length), buffer);
    814815                        if (result <= 0) break;
    815816                }
     
    939940        checkWidget ();
    940941        if (index == -1) return;
    941         int rc = OS.WinSendMsg (handle, OS.LM_SELECTITEM, (short)index, OS.TRUE);
    942         if(rc != OS.FALSE)
    943             sendEvent (SWT.Modify);
     942        int count = OS.WinSendMsg (handle, OS.LM_QUERYITEMCOUNT, 0, 0);
     943        if(0 <= index && index < count){
     944                int selection =  OS.WinSendMsg (handle, OS.LM_QUERYSELECTION, (short)OS.LIT_CURSOR, 0);
     945                int rc = OS.WinSendMsg (handle, OS.LM_SELECTITEM, (short)index, OS.TRUE);
     946                if(rc != OS.FALSE && rc != selection)
     947                    sendEvent (SWT.Modify);
     948        }
    944949}
    945950
Note: See TracChangeset for help on using the changeset viewer.