Clipboard text reverts to last clipboard text?

I suck at explaining, I will delete the video once i have an answer, but can someone tell me what it is im doing wrong?

im using the new clipboard item from docs

Dim c As New Clipboard MsgBox Me.Text c.Text =me.Text c.Close

except, its not working as intended.

  1. The inner window is a container, instantiated everytime the user double clicks a client name, so theres no past properties used, no global variables that would save last seen data…yet its somehow reverting back

  2. Me.text is the current text, so why revert?

what am i looking for?

watch video for what happens… 1 minute long

https://youtu.be/Q6GdYsZhl_c

Me.Text is not the current text. It is the text contained in the owning Control (the control where the code - above - reside).
So, you store the Text of a Control (TextField/TextArea or Label ?), probably not what you want.

Try instead c.Text = My_Control_Name.Text

Your MsgBox returns the wrong text too.

PS: the video is unavailable now (for me).

try this - https://www.youtube.com/watch?v=Q6GdYsZhl_c

I changed it to the control name - no affect. I was thinking maybe it was confused on the “me” value, but no. I’m still lost.

You got two message boxes the second time. It’s not reverting, it’s happening more than once.

If you try a third contact, do you get three message boxes?
It could be that you’re not closing the previous container, and the click is going through to the one no longer in view.

Same. I am in Europe (France), this may be the reason. Check the region in you tube.

Add a Break and watch (step) in the Debugger what happens (what is stored when its value is changed). It always helps.

Using a MsgBox for debug is not always a good idea.

I checked youtube and the only box i didn’t mark was that content never aired on US television - Distribution set to everywhere. Sorry, my loss I guess.

@Tim Parnell - Yes, 3 boxes appear.

OK. So, I assume I’m not closing the container. But can someone explain why that matters here?

So, I’ve been learning about how to dynamically draw and embed things into a canvas. It’s allowed me to really make things flexible and less cluttered.

this container is an embedded container. Not actually added to the window.

dim cc as new containername canvas1.embed(cc)

how do I programatically close the previous container when its not a global variable? I thought when you “Dim” something as “NEW” with the same name that it overwrites it…

I’m guessing that it does overwrite it, but the canvas had it embedded before, so that means It’s still embedded even though a new instance of the same name is embedded.

ALL my containers are embedded by the name “cc”

Yet that makes no sense to me. If I dim something as new with the same name and embed it - why wouldn’t it just overwrite whatever was there to begin with?

OK so maybe I don’t need to “close” the cc… since it overwrites in program.

Its the canvas I have to worry about right? how do I refresh the canvas as a clean slate?

Canvas1 = Nil ?

@Emile Schwarz hahahaha, it couldn’t be that simple

for shits and giggles i tried it, nope lol

As I put the cursor towards the top of the window, I see the resize column icon appear even though no list-box is there. So it is confirmed, the canvas always has whatever was embedded last on it. New embeds just overlap it. EVEN if what you embed on the canvas has the same name.

so Why is this the case?
and How do I clear the canvas?

You’re using MouseDown, so since the control still exists underneath it’s MouseDown event is still firing. You need to close the containers when they’re not in view, you’re wasting the memory for each container opened and then not closed.

Nope. Stop right there. You need to embed the container into the Window, not a Canvas. ContainerControl (deprecated) — Xojo documentation

Maintain a reference to the ContainerControl you’re instancing and embedding. When the user navigates away from the detail view, close the container.

Yes.

Not so close. The instance that’s embedded stays in scope, embedded into the window. The variable you’d used to do so is your last accessible reference to it. You should store that reference before replacing it. If you destroy the reference but not the embedded container you have to reacquire a reference to the container which isn’t as easy as just keeping the reference in the first place.

You need better variable names if you want to understand the code in six months.

When you embed the control into a window, you’re adding the control to a window. What you’re doing is not removing that control from the window. You’re just missing a step.

Yes. You do. It does not get “overwritten” since you’re embedding it.

You need to remove the canvas, and embed properly into the window.

Canvas.Invalidate will cause another Paint event, but it’s likely not what you actually want.

Maintain a reference to the container as a property of the window. We’re going to drop the canvas and embed correctly in this example.

  1. Create a property on the window, oOpenDetailView as ccMyDetailViewContainer.

  2. Store the instance of the container when you embed

dim oNew as new ccMyDetailViewContainer oOpenDetailView = oNew oNew.EmbedWithin(self, 0, 0)

  1. When the user exits the detail view, close the container

oOpenDetailView.Close oOpenDetailView = nil

And frankly I’m surprised you’re getting mouse events for a container embedded into a canvas. I would have expected embedding into a canvas to embed as an image, and not usable controls.

Well, using a canvas instead of a window has the advantage of enabling scrolling for the controls it contains.

You can create scrolling for containers with just a pinch of extra effort. Adjusting the .Top of the container to be scrolled will do the trick. Whether you need a containing container or if it’ll work on the window itself depends on the case. I would be curious if there are system level benefits to doing so.

@Tim Parnell is the one who answered the question, Thank you for the time you spent helping a noob.

If you embed a Container Control in a Canvas, or anywhere dynamically, and you are embedding that container - you have to close it before embedding another in the same place - or risk issues such as code firing multiple times.

  1. Create a global property as Container Control (Ie. ccx | ContainerControl)
  2. Embed, but be sure to assign the embedded container…

Dim cc as new MyContainerControlName // Create a new instance of your Container Control ccx=cc // Assign your new instance to the ContainerControl Property cc.EmbedWithin(Canvas1,0,0,Canvas1.width,canvas1.Height) // Embed your Container Control

  1. Now you can call the close event from anywhere… even at the start of your method.
ccx.close()
  • IF you place the code to close a container at the beginning of a method that loads a number of containers to the same canvas, remember that when the application first starts, no container exists and the close event will result in a NilObjectException.
  1. Create a global property as integer with a default of “0” (Ie. ccx_isopen | 0)
  2. Create an IF statement to check if any container has been created yet…

If ccx_isopen=0 then ccx_isopen=1 else ccx.close() end