listbox dragging to a TextArea problem.

In my app, I drag items from a listbox to a TextArea, which triggers a window to open prompting for fields to be answered, which is then written to the TextArea. This works fine if the TextArea is set to read-only, When the TextArea is set to be writable, my window no longer pops up, and the text of the listbox item is written to the TextArea instead.

How do I get this to function the same as when the TextArea is set to read only?

On Windows.

Since you’ve not yet received a reply, I’ll chime in that I would need to see code for this process…

before I could begin to speculate about what is happening.

The code is all over, in a Method, listbox and TextArea.

The Windows I have that trigger are in a method, but that alone isn’t going to help you. That’s pretty straight-forward.

I’d imagine it’s in the Listbox and Textarea.

So, under Listbox:CellClick I have

cellName = me.cell(row, column)

and under ListBox:Dragrow I have

[code] drag.Text = me.list(row)

Return True[/code]

Under the TextArea:Open I have

me.AcceptTextDrop

and under TextArea:Drop Object I call my Method, which opens the windows based on what cell name is dragged.

As I understand this, you open a separate Window with fields. The user-entered text in those fields is then used to populate the TextArea upon return to the original window. How are the strings from those text fields being passed back to the original window?
How are those strings put into the textArea? Append? TextArea.Text = String?

I’ve done it two ways. I wrote to a text file then refreshed the TextArea, and I’ve also written to the TextArea directly. I’ve used Append and SelText.

Both have the same issue. The drop doesn’t kick off the method if the TextArea is not set to Read Only.

I have the listbox setup to run the method on a double click as well, and that works correctly.

You could overlay a canvas on the textArea to accept the drop, then handle it as needed. Ignore mouse clicks etc

If I add a canvas, I can get the Method to trigger. However, if I overlay the canvas over the TextArea, it fails to trigger the method, and continues to write the text of the cell I dragged, even when I disable me.accepttextdrop.

Anyone have ideas on how I can drag a cell from a ListBox onto a Editable TextArea and trigger a method instead of it just witting the cell name into the TextArea?

This looks like a bug to me. I don’t see anything in feedback, so you should probably start a case.
Looks like the canvas is superceded by the textarea…
The only workaround I can think of is to make the canvas larger than the textarea and set textarea.readonly in the drageneter/dragexit/dropobject events. Not 100% reliable though… kind of a hack :confused:

[quote=213990:@jim mckay]This looks like a bug to me. I don’t see anything in feedback, so you should probably start a case.
Looks like the canvas is superceded by the textarea…
The only workaround I can think of is to make the canvas larger than the textarea and set textarea.readonly in the drageneter/dragexit/dropobject events. Not 100% reliable though… kind of a hack :/[/quote]

Ultimately, I don’t want to use the canvas, because I want to control where the cursor goes when it writes to the TextArea.

Here is a project where the text dropped triggers a MsgBox when text is pasted into the TextArea, by dragging it from a ListBox, or from the menu. It can trigger any other method.

I have simply modified the ListBoxesDragandDrop example project.

The trick is to set a boolean flag in KeyDown to know when text is entered from the keyboard. If not, then the additional text is extracted, and the Text property of the TextArea is reinstated.

Everything takes place in the TextArea KeyDown and TextChanged events, with the help of the properties isKey as Boolean, Selstart as Integer, Text as String and TextLength as Integer.

ListBoxesDragAndDropToText.xojo_binary_project

It is a quick proof of concept and will need more refinements to manage deletions from the menu or right click. But the principle of the workaround remains.

Now we’re starting to get somewhere.

However, if I just add my action to the TextChange code as is, the drag fires off the method, but any entries into the widow fields are not written to the TextArea.

If I remove the Me.Text = Text then it generally works like I want it to, but it first writes the cell name before writing the results of the window fields. I can’t have the cell name in there.

[quote=214020:@Niles Mitchell]Now we’re starting to get somewhere.

However, if I just add my action to the TextChange code as is, the drag fires off the method, but any entries into the widow fields are not written to the TextArea.

If I remove the Me.Text = Text then it generally works like I want it to, but it first writes the cell name before writing the results of the window fields. I can’t have the cell name in there.[/quote]

What do you want to obtain exactly ? Could you try to describe that step by step ?

Here’s an idea… in the dragRow event, change the drag.text to some unique token (you could check the textarea for it’s existence just to be safe and ensure it’s unique), then in the textchange event, check for the token in the textarea.text. If it exists, set selstart and sellength, then use seltext to replace the token. This way, you’ll know when text changed via drop, and be able to place the new text in the dropped position.

I am making a front end for AutoIT. I have a list of commonly used commands on the left side of the screen in a ListBox and a TextArea on the right. I want to be able to drag the commands into an editable TextArea. This triggers a window based on the command dragged, which has fields that need to be entered. The AutoIT code is then written to the TextArea. If you’ve ever used WiseScript, it’s sorta similar.

I have the ListBox setup to double-click, and this works just fine, as well as if I lock down the TextArea to Read-Only. However, I want to be able to edit the code manually in the TextArea as well as drag commands to a specific spot in the code.

This is where I’m running into trouble, and I encounter the issues I’ve mentioned above.

[quote=214032:@Niles Mitchell]I am making a front end for AutoIT. I have a list of commonly used commands on the left side of the screen in a ListBox and a TextArea on the right. I want to be able to drag the commands into an editable TextArea. This triggers a window based on the command dragged, which has fields that need to be entered. The AutoIT code is then written to the TextArea. If you’ve ever used WiseScript, it’s sorta similar.

I have the ListBox setup to double-click, and this works just fine, as well as if I lock down the TextArea to Read-Only. However, I want to be able to edit the code manually in the TextArea as well as drag commands to a specific spot in the code.

This is where I’m running into trouble, and I encounter the issues I’ve mentioned above.[/quote]

So as far as I understand, now from the example I posted you are able to display the window with the textfields onto it, but the entries there do not show in the TextArea of the original window ?

You need to copy the content of your TextFields to the TextArea.Text property.

I am. Like I said, they work with the doubleclick or if the TextArea is locked.

You must be missing something along the way. Difficult to guess what.

With the code you gave me, I can get it to do what I want…minus the fact that it’s still dropping in the CellName text in addition to the text I’m writing from the command windows.

I just need to figure out how to stop it from writing the cellname.