Cut the selectedChunk

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
WaltBrown
Posts: 466
Joined: Mon May 11, 2009 9:12 pm

Cut the selectedChunk

Post by WaltBrown » Sat Oct 01, 2011 9:06 am

Hi! I am missing something simple.

I have "put the selectedChunk into gVariable" in an unlocked field for a mouse click which pops up a menu button.

In the menu button pick handler I put "cut gVariable". Obviously I declare gVariable in both handlers. (I cannot simply use "cut" because the field loses focus when the menu pops up).

gVariable contains "char 178 to 191 of field 1" - the field number rather than it's name.

When executed it cuts the entire field object, not the selection.

What am I missing? It's got to be something really simple, I'm just brain dead and can't find it.

Thanks, Walt
Walt Brown
Omnis traductor traditor

WaltBrown
Posts: 466
Joined: Mon May 11, 2009 9:12 pm

Re: Cut the selectedChunk

Post by WaltBrown » Sat Oct 01, 2011 9:10 am

I wonder if this is related to bug report 7766?
Walt Brown
Omnis traductor traditor

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10320
Joined: Wed May 06, 2009 2:28 pm

Re: Cut the selectedChunk

Post by dunbarx » Sat Oct 01, 2011 5:14 pm

Odd, indeed. How could this have gone unnoticed?

Just so you know, this works:

Code: Select all

on mouseup
   put the selectedChunk into temp
   do "cut" && temp
end mouseUp
I will have to see if HC exhibits the same...

Craig Newman

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10320
Joined: Wed May 06, 2009 2:28 pm

Re: Cut the selectedChunk

Post by dunbarx » Sat Oct 01, 2011 5:32 pm

Now this thing is intermiitant. I made a few fields, ran the code in several ways:

on mouseup --this never fails
cut the selectedChunk
end mouseUp

on mouseup -- this is intermiittant, field disappeared several times, but not always
put the selectedChunk into temp
cut temp
end mouseUp

on mouseup --this never fails
put the selectedChunk into temp
do "cut" && temp
end mouseUp

But now I cannot duplicate the bug at all. Everything works fine. ("I got better...") I will try a new session.

Ah. It turns out that closing and reopening a stack will cause this to happen once. Once the bug occurs, and a field is deleted, then all subsequent runs work just fine, even with new fields. I am sure we can all write scripts on preOpenStack to create a field, lose it, and then leave everything just ducky.

Craig Newman

WaltBrown
Posts: 466
Joined: Mon May 11, 2009 9:12 pm

Re: Cut the selectedChunk

Post by WaltBrown » Sun Oct 02, 2011 1:52 am

Craig,
The issue I had also involved a popup menu (where the "cut" is executed), and I think that changes focus, and mangles something somewhere. I can also cut from within a field's script, it's the popup which seems to mess things up.
Walt
Walt Brown
Omnis traductor traditor

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10320
Joined: Wed May 06, 2009 2:28 pm

Re: Cut the selectedChunk

Post by dunbarx » Sun Oct 02, 2011 5:32 am

Walt.

I put in a bug report. The way I do it is reproducable. And really odd.

# 9778.

Craig

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am

Re: Cut the selectedChunk

Post by marksmithhfx » Sun Oct 02, 2011 6:13 am

WaltBrown wrote:Craig,
The issue I had also involved a popup menu (where the "cut" is executed), and I think that changes focus, and mangles something somewhere. I can also cut from within a field's script, it's the popup which seems to mess things up.
Walt
Hi Walt, I can confirm "do "cut" && gvariable" works in a popup on both Mac's and PC's. No evidence of 7766 there. I'm posting my test program.

-- Mark

PS the "cut" script is in Choice 1 on the popup
Attachments
test1.livecode.zip
test of cutting text in a field with a popup choice
(1.08 KiB) Downloaded 257 times
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

WaltBrown
Posts: 466
Joined: Mon May 11, 2009 9:12 pm

Re: Cut the selectedChunk

Post by WaltBrown » Tue Oct 04, 2011 4:01 am

Thanks. I guess "cut" will remain buggy if called directly. I'll remember to use the 'do "cut"' instead.
Walt Brown
Omnis traductor traditor

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10320
Joined: Wed May 06, 2009 2:28 pm

Re: Cut the selectedChunk

Post by dunbarx » Tue Oct 04, 2011 4:07 am

The bug is confirmed by QCC. Still hard to believe this was never noticed.

I still intend to check HC, but I don't expect to find it there.

Craig Newman

Post Reply