Double click field, to unlock text and edit
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Double click field, to unlock text and edit
Hi,
I have a series of fields on a card that I want to keep locked via locktext.
When the user double-clicks on it, I want the field to activate, and let the double-click pass through.
Is that possible? If not, what's the easiest way to unlock the text, and select after the text?
Thank you,
-Chilton
I have a series of fields on a card that I want to keep locked via locktext.
When the user double-clicks on it, I want the field to activate, and let the double-click pass through.
Is that possible? If not, what's the easiest way to unlock the text, and select after the text?
Thank you,
-Chilton
-
- VIP Livecode Opensource Backer
- Posts: 9670
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Double click field, to unlock text and edit
Hi.
So if the locktext of a field is "true", then it receives such events as "mouseUp", no? And if it does that, why not use "mouseDoubleUp" to simply unlock the text. Maybe you can relock on mouseLeave?
Others will chime in here, but there is a bit of a conflict when you have a mouseUp and a mouseDoubleUp handler in the same object script. Just for your information. The solution, and I am just old fashioned that way, is this:
Try it, you'll like it.
Craig Newman
So if the locktext of a field is "true", then it receives such events as "mouseUp", no? And if it does that, why not use "mouseDoubleUp" to simply unlock the text. Maybe you can relock on mouseLeave?
Others will chime in here, but there is a bit of a conflict when you have a mouseUp and a mouseDoubleUp handler in the same object script. Just for your information. The solution, and I am just old fashioned that way, is this:
Code: Select all
on mouseUp
wait 20
if the mouseClick then doDoubleClickStuff
else doSingleClickStuff
end mouseUp
Craig Newman
Re: Double click field, to unlock text and edit
I have encountered a similar issue, mine involving on openField.
My problem is that with on openField, doubleMouseUp doesn't work.
I tried this as suggested
on openField
wait 20
if the mouseClick then
doDoubleClickStuff
end if
do openFieldStuff
end openField
My problem that is causing this not to work is the the next field will open right of way and the user needs time to decide if he/she is going to double click the next field or not. So if he waits longer than 20 milliseconds then the doDoubleClickStuff wont trigger.
My problem is that with on openField, doubleMouseUp doesn't work.
I tried this as suggested
on openField
wait 20
if the mouseClick then
doDoubleClickStuff
end if
do openFieldStuff
end openField
My problem that is causing this not to work is the the next field will open right of way and the user needs time to decide if he/she is going to double click the next field or not. So if he waits longer than 20 milliseconds then the doDoubleClickStuff wont trigger.
"Det bästa stället att hitta en hjälpande hand är i slutet av din egen arm" förutom här
-
- VIP Livecode Opensource Backer
- Posts: 9670
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Double click field, to unlock text and edit
Hi.
First off, "wait 20" i s 20 ticks, not 20 ms, or about a third of a second. Or was that just a typo?
I assume your fields are unlocked, right? But a mouseClick is not registered if you simply click in an unlocked field, so no mouseUp or mouseDoubleUp messages are sent at all.
Theoretically, your point, if I understand it, is that the "openField" message and whatever action that invokes it, not being "on the mouse", is dicey to time. I agree. Opening a field does not involve the user in nearly the same way. The two types of actions are disconnected and use different muscles, so to speak.
But getting back to making something work, if you are simply clicking in an unlocked field:
Oddly, this only works if there is at least one char in that field. Therefore I advise you to rethink this beyond that little handler. It is usually far better to change your methodology than to struggle to make a troublesome one work.
Craig
First off, "wait 20" i s 20 ticks, not 20 ms, or about a third of a second. Or was that just a typo?
I assume your fields are unlocked, right? But a mouseClick is not registered if you simply click in an unlocked field, so no mouseUp or mouseDoubleUp messages are sent at all.
Theoretically, your point, if I understand it, is that the "openField" message and whatever action that invokes it, not being "on the mouse", is dicey to time. I agree. Opening a field does not involve the user in nearly the same way. The two types of actions are disconnected and use different muscles, so to speak.
But getting back to making something work, if you are simply clicking in an unlocked field:
Code: Select all
on selectionChanged
wait 20
if the mouseClick then put "double" else put "single"
end selectionChanged
Craig
Re: Double click field, to unlock text and edit
I suppose I can elaborate on what I currently have and what I want to add.
right now I have the on openField handler to gather any information that is already in the field.
on openField
put fld "Field" into "oldData"
end openField
and then when the field is closed it saves to a log file.
on closeField
put fld "Field into "newData"
if "oldData" <> "newData" then
--put user changed oldData to newData in a log file.
end if
end closeField
A request came up to add a double click functionality to the fields so that the user can double click to change the record for example from yes to no.
on mouseDoubleUp
put fld "Field" into "oldData"
if "oldData" = "Yes" then
put "No" into fld "Field"
end if
closeField
end mouseDoubleUp
And I did think wait was counted in ms, thank you for correcting me on that, I don't like being ignorant.
right now I have the on openField handler to gather any information that is already in the field.
on openField
put fld "Field" into "oldData"
end openField
and then when the field is closed it saves to a log file.
on closeField
put fld "Field into "newData"
if "oldData" <> "newData" then
--put user changed oldData to newData in a log file.
end if
end closeField
A request came up to add a double click functionality to the fields so that the user can double click to change the record for example from yes to no.
on mouseDoubleUp
put fld "Field" into "oldData"
if "oldData" = "Yes" then
put "No" into fld "Field"
end if
closeField
end mouseDoubleUp
And I did think wait was counted in ms, thank you for correcting me on that, I don't like being ignorant.
"Det bästa stället att hitta en hjälpande hand är i slutet av din egen arm" förutom här
-
- VIP Livecode Opensource Backer
- Posts: 9842
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Double click field, to unlock text and edit
I'm having a hard time visualizing what's needed there. If you could describe a bit more the experience you want to deliver to your user I'll bet we can find a good way to make that happen.DavJans wrote:My problem that is causing this not to work is the the next field will open right of way and the user needs time to decide if he/she is going to double click the next field or not. So if he waits longer than 20 milliseconds then the doDoubleClickStuff wont trigger.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- VIP Livecode Opensource Backer
- Posts: 9670
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Double click field, to unlock text and edit
Hmmm.
Firstly, you cannot put data into a literal. It would not compile. I assume that when you wrote:
you really meant:
A line like:
will always return "false", because the two literals are different, and you really wanted to know if two variables were different.
You have to declare a script local variable for oldData and newData, or the two handlers will not know what the other is talking about. Do you know how to do this? Do you know why? Also, I would rename the field from its default. That usually causes trouble.
And since an unlocked field does not send "mouseDoubleUp", this entire approach is just not tenable.
So.
What could we do differently? Keep at it; this is the very best way to learn. We are here day and night.
Craig
Firstly, you cannot put data into a literal. It would not compile. I assume that when you wrote:
Code: Select all
put fld "Field" into "oldData"
Code: Select all
put fld "Field" into oldData --a variable, not a literal
Code: Select all
if "oldData" <> "newData" then
You have to declare a script local variable for oldData and newData, or the two handlers will not know what the other is talking about. Do you know how to do this? Do you know why? Also, I would rename the field from its default. That usually causes trouble.
And since an unlocked field does not send "mouseDoubleUp", this entire approach is just not tenable.
So.
What could we do differently? Keep at it; this is the very best way to learn. We are here day and night.
Craig
Re: Double click field, to unlock text and edit
Well I'm just making myself look really smart.
Here is my actual script in the fields on my card, they are all almost the same. In this example we would want something like a doubleMouseUp to put their user number in the field and then over on to the next field.
Here is my actual script in the fields on my card, they are all almost the same. In this example we would want something like a doubleMouseUp to put their user number in the field and then over on to the next field.
Code: Select all
global gConnectionID
global currentBay
local hOldRecord
on openField
put fld "dimensions" into hOldRecord
end openField
on closeField
replace "," with "/" in me
put fld "dimensions" into tDimensions
put fld "certn" into tCertN
put fld "jobn" into tJobN
put "UPDATE tracker SET trackerdimensions = '" & tDimensions & "' WHERE (trackerjob = '" & tJobN & "' and trackercert = '" & tCertN &"');" into tSQL
send dbOpen to stack "Metals Fab Tracker"
revExecuteSQL gConnectionID, tSQL
if currentBay <> "" then
put "UPDATE tracker SET trackerloc = '" & currentBay & "' WHERE (trackerjob = '" & tJobN & "' and trackercert = '" & tCertN &"');" into cSQL
revExecuteSQL gConnectionID, cSQL
end if
put the short date into hDate
put the short time into hTime
put fld "certn" into hCert
put fld "user" into hQC
put "Dimensions" into hChangedRecord
put fld "dimensions" into hNewRecord
if hOldRecord <> hNewRecord then
put "date, time, cert, qc, changedrecord, oldrecord, newrecord" into hFields
put "INSERT INTO history (" & hFields & ") VALUES (:1, :2, :3, :4, :5, :6, :7)" into tSQL
revExecuteSQL gConnectionID, tSQL, "hDate", "hTime", "hCert", "hQC", "hChangedRecord", "hOldRecord", "hNewRecord"
end if
focus on fld "parts"
send finalQcCheck to card "Tracker"
send dbClose to stack "Metals Fab Tracker"
end closeField
"Det bästa stället att hitta en hjälpande hand är i slutet av din egen arm" förutom här
Re: Double click field, to unlock text and edit
We have a button that does this for them but I guess its not convenient enough
Code: Select all
on mouseUp
put the number of the selectedField into currentField
put fld "user" into qQC
put qQC into the selection
Send closeField to fld currentField
select the text of fld (currentField + 1)
end mouseUp
"Det bästa stället att hitta en hjälpande hand är i slutet av din egen arm" förutom här
-
- VIP Livecode Opensource Backer
- Posts: 474
- Joined: Thu Sep 04, 2008 6:23 am
- Location: Melbourne Australia
Re: Double click field, to unlock text and edit
Hi Davian's,
Providing the scripts is one thing.
Knowing what you want to achieve is soemtimes quite different.
Could you explain in simple steps what the user is presented with and what you want them to do/to happen'?
E.g.
1. Card opens
2. Fields showing the following data are filled: user, dimensions, ....
3. User clicks in field "xxx"
4. User
A) clicks somewhere else - old filed stays same.
B) modifies data in field and then clicks/tabs elsewhere- new data processed, saved to'?
Get the idea'?
The scripts you have provided seem to have unnecessary steps.
Also, have you looked at the message "textchanged"
Providing the scripts is one thing.
Knowing what you want to achieve is soemtimes quite different.
Could you explain in simple steps what the user is presented with and what you want them to do/to happen'?
E.g.
1. Card opens
2. Fields showing the following data are filled: user, dimensions, ....
3. User clicks in field "xxx"
4. User
A) clicks somewhere else - old filed stays same.
B) modifies data in field and then clicks/tabs elsewhere- new data processed, saved to'?
Get the idea'?
The scripts you have provided seem to have unnecessary steps.
Also, have you looked at the message "textchanged"
Re: Double click field, to unlock text and edit
the script does need to be cleaned up its one of the first things I wrote when I first started learning how to code
OK, lets see, we manufacture steel for sky scrapers, to the user is our quality control people that check the steel. Each piece of steel has an ID.
The card has 24 fields the first field being where they input the ID of the steel they are looking at to make sure it is correct.
When they put in the id and hit enter we query the database to see if it exists, if it does populate the data in the other fields if such data exists. if not then add the id to the database.
After the id is entered. it automatically focuses on the next field. And for the rest of the fields as they check each item record their employee number to say I checked this and it is good then it advances to the next field.
Their Idea to make their job faster was to double tap the field to have it put in their id instead of having to type it over and over again all day.
OK, lets see, we manufacture steel for sky scrapers, to the user is our quality control people that check the steel. Each piece of steel has an ID.
The card has 24 fields the first field being where they input the ID of the steel they are looking at to make sure it is correct.
When they put in the id and hit enter we query the database to see if it exists, if it does populate the data in the other fields if such data exists. if not then add the id to the database.
After the id is entered. it automatically focuses on the next field. And for the rest of the fields as they check each item record their employee number to say I checked this and it is good then it advances to the next field.
Their Idea to make their job faster was to double tap the field to have it put in their id instead of having to type it over and over again all day.
"Det bästa stället att hitta en hjälpande hand är i slutet av din egen arm" förutom här
-
- VIP Livecode Opensource Backer
- Posts: 9670
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Double click field, to unlock text and edit
OK.
Whether the ID exists or not, why not store it (once it is finalized) in a custom property of the card, and then load it whenever a new field is opened. This can be done by trapping "openField" or "tabKey", say, or any other method that corresponds nicely with the way you navigate from field to field.
Does this fit? Write back...
The important thing to learn here is that, oftentimes, rethinking the method entirely is better than struggling with what you started out with.
Craig
Whether the ID exists or not, why not store it (once it is finalized) in a custom property of the card, and then load it whenever a new field is opened. This can be done by trapping "openField" or "tabKey", say, or any other method that corresponds nicely with the way you navigate from field to field.
Does this fit? Write back...
The important thing to learn here is that, oftentimes, rethinking the method entirely is better than struggling with what you started out with.
Craig
Re: Double click field, to unlock text and edit
I don't think i understand your question
The ID of the material is only used the one time, the rest of the time they put in their employee number.
If it is loaded automatically during openField, what if the the camber field opens but they haven't checked it yet. so now wouldn't they have to remove their Number, so the same thing but back words?
The ID of the material is only used the one time, the rest of the time they put in their employee number.
If it is loaded automatically during openField, what if the the camber field opens but they haven't checked it yet. so now wouldn't they have to remove their Number, so the same thing but back words?
"Det bästa stället att hitta en hjälpande hand är i slutet av din egen arm" förutom här
-
- VIP Livecode Opensource Backer
- Posts: 474
- Joined: Thu Sep 04, 2008 6:23 am
- Location: Melbourne Australia
Re: Double click field, to unlock text and edit
So, assuming that the user has logged into the system (else anyone could tamper with the data) their ID is already known to the current session.
As you are recording the user ID I am also assuming it is currently present for each item of data for a particular material ID.
So, when the material ID is entered and an existing record appears, each component of that record will also display a user ID for the user that entered that data, unless it came from some other source.
Why not just have a checkbox next to each field, say between it and the user id field.
If the text changes in the item field, the checkbox is enabled.
If the checkbox is then clicked, the current user id is entered against that item field.
If the checkbox is not checked then it is not (and the record can't be saved!)
The user id field need only be read only as it just needs to display who did the editing.
If the current user is doing some editing then, as they needed to identify themselves to access the system their id is known to it and doesn't need to be typed in against each edit, the system simply enters it. This way also ensures user A cannot enter an edit for user B.
This provides a single click confirmation against each field edit and a system enforced identification of the editor.
As you are recording the user ID I am also assuming it is currently present for each item of data for a particular material ID.
So, when the material ID is entered and an existing record appears, each component of that record will also display a user ID for the user that entered that data, unless it came from some other source.
Why not just have a checkbox next to each field, say between it and the user id field.
If the text changes in the item field, the checkbox is enabled.
If the checkbox is then clicked, the current user id is entered against that item field.
If the checkbox is not checked then it is not (and the record can't be saved!)
The user id field need only be read only as it just needs to display who did the editing.
If the current user is doing some editing then, as they needed to identify themselves to access the system their id is known to it and doesn't need to be typed in against each edit, the system simply enters it. This way also ensures user A cannot enter an edit for user B.
This provides a single click confirmation against each field edit and a system enforced identification of the editor.
-
- VIP Livecode Opensource Backer
- Posts: 9670
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Double click field, to unlock text and edit
I don't understand your question.
Craig
What is the text that you do not want to have to enter over and over? Whatever it is, it can be extracted, stored and then loaded automatically, in any way of your choosing.Their Idea to make their job faster was to double tap the field to have it put in their id instead of having to type it over and over again all day.
Craig