Modify

Opened 13 years ago

Closed 13 years ago

#1924 closed Bug (No Bug)

Hiding one Edit affects the text in another.

Reported by: martin Owned by:
Milestone: Component: AutoIt
Version: 3.3.6.1 Severity: None
Keywords: GuiCtrlSetStae with Edits Cc:

Description

The code below shows the problem. If you run the code with the alternative lines which include the ENABLED or DISABLE|D state of the hidden Edit then the other edit is not affected.
I can't reproduce this in GuiOnEventMode.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <guiedit.au3>

Opt("MustDeclareVars", 1)


GUICreate("Form2", 400, 298, 302, 218)
Local $Edit1 = GUICtrlCreateEdit("Edit1", 10, 46, 120, 204)
Local $Edit2 = GUICtrlCreateEdit("Edit2", 140, 46, 120, 204)
GUISetState(@SW_SHOW)

Local $s
For $i = 0 To 6;make some lines to put in edit2
    $s &= "------------> " & $i & @CRLF
Next


GUICtrlSetData($Edit2, $s, "1");insert the lines
Sleep(2000)


GUICtrlSetState($Edit1, $GUI_HIDE);after this line, adding a line to edit2 replaces the existing text

;GUICtrlSetState($Edit1, BitOr($GUI_DISABLE, $GUI_HIDE));but text not cleared using this line instead


GUICtrlSetData($Edit2, "---another--> 6" & @CRLF, "1"); should be appended but replaces exiting text
Sleep(4000)

Attachments (0)

Change History (2)

comment:1 Changed 13 years ago by MrCreatoR <mscreator@…>

Indeed, strange behaviour.

comment:2 Changed 13 years ago by Valik

  • Resolution set to No Bug
  • Status changed from new to closed

This is not a bug. I do not like this behavior in AutoIt, but it is not a bug. When you disable $Edit1 Windows (Not AutoIt) shifts focus to $Edit2. When it does this it is secretly selecting the entire contents of $Edit2. You can verify this by using _GUICtrlEdit_GetSel() before and after the GUICtrlSetState() line. Now comes the part about AutoIt that I don't like. AutoIt is designed so that it inserts at the current caret location. If there is no text selected this is just a normal insertion. If there is text selected then it becomes a replace. So, since Windows selected the entire text of $Edit2 all of it is replaced.

My suggestion is use _GUICtrlEdit_AppendText() to append to the end of an edit control. It takes the extra step necessary to ensure it always appends and never replaces. You could also use _GUICtrlEdit_SetSel() to adjust the selection yourself before calling GUICtrlSetData().

Closing as no bug.

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The ticket will remain with no owner.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.