How to blank off some cells in table field

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
user#606
Posts: 217
Joined: Sun Jan 27, 2008 12:25 pm
Contact:

How to blank off some cells in table field

Post by user#606 » Wed Mar 13, 2013 2:30 pm

Hi, Me again.

I propose to use a single table field to hold text as a simple way of holding program settings.
So the grid has headings within it and at fixed, but not symetrical positions over it, I had hoped to place a label field on top of the cell, set to top layer, opaque and disabled and Fixed in position. This looks great, but allows the undesirable effect of allowing access to the cell underneath it.
Is there any way of making the label field, or some similar technique, into an impenatrable barrier to the cell under it?

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: How to blank off some cells in table field

Post by sturgis » Wed Mar 13, 2013 3:49 pm

If I understand what you want, you are trying to store settings in a field, but want them to only be changeable by script and to keep the user from being able to directly edit a setting by clicking a cell?

If so, the easiest way is to:

make sure locktext is on for the field
go to the table pane in the property inspector for that field and take the check out of cRevTable[celledit] -- may show up with a different name depending on your settings

If you need to have SOME changeable, you can set up the editable ones as links so that when they're clicked your app knows to pop up an edit dialog of some type.

user#606
Posts: 217
Joined: Sun Jan 27, 2008 12:25 pm
Contact:

Re: How to blank off some cells in table field

Post by user#606 » Wed Mar 13, 2013 3:59 pm

No, the table is exposed for direct keyboard editing.
The purpose of the lable field was to cover a cell that has no input.
Sadly, I can find no way of preventing access through whatever I use to cover the non-useable cell.

I was hoping for a quick and direct solution, rather than the edit box as a result of a clicked cell.
It is so easy to save and reload a table, compared to many detailed lines of a text file holding the settings.

Looks like I am a "stuffed bunny" on this one.

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: How to blank off some cells in table field

Post by sturgis » Wed Mar 13, 2013 4:21 pm

Just re-read what you wrote before about your label fields. Don't disable them and try again! Should work dandy. If you want the nice grey look of the disabled text just change the color in the field properties for that label.

user#606
Posts: 217
Joined: Sun Jan 27, 2008 12:25 pm
Contact:

Re: How to blank off some cells in table field

Post by user#606 » Wed Mar 13, 2013 4:35 pm

Hi, Thanks for that.
The snag is that you can tab across and the cell under the field is enterable.

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: How to blank off some cells in table field

Post by sturgis » Wed Mar 13, 2013 7:11 pm

Been thinking on it, think I may have a solution that will work, but have to do a road trip before I can work the rest of it out. (3 hours there, appt, 3 hours home *gag*)

Basically its using setting linktext for the items you want to be editable, leave the field locked and if the click is valid show a field (exactly like the grid does it currently) allowing for edit. As mentioned this would require turning off the cEditField stuff in the properties of the table grid, but thats easy enough to do.

I'd already have a sample done for you but the way linktext works now is.. Different and unpredictable. (well ok its predictable, i'm just having to figure out a different method than expected to set things up) Kinda a pain but like I said, I think I have a method figured out that will do this and will pop out a sample this evening when I get home.

user#606
Posts: 217
Joined: Sun Jan 27, 2008 12:25 pm
Contact:

Re: How to blank off some cells in table field

Post by user#606 » Wed Mar 13, 2013 8:32 pm

Hi, That suggestion looks interesting.
I look forward to your solution.
Kind regards

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: How to blank off some cells in table field

Post by sturgis » Thu Mar 14, 2013 3:40 am

Just got home, really rough day. And yes I think it will work, but no I haven't yet worked out the kinks. May not hear from me tonight, has one of those days. 6 hours on the road, 2 hours at the hospital! (I love appointments that are way too far away don't you?)

Sorry for the delay, just too too much goin on. You might experiment with linktext and setting the textstyle of things to link to get a handle on em. I'm having to re-learn what I thought I knew and haven't got thigns to work the way I expect them to yet but surely its possible.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: How to blank off some cells in table field

Post by Simon » Thu Mar 14, 2013 4:30 am

Hi,
Maybe you are making this too difficult by using the table fld.

Code: Select all

on mouseUp
   put 0 into S
   put 0 into T
   repeat with Q = 1 to 10
   repeat with N = 0 to 9
      create fld "g"&Q&N
      set the rect of fld ("g"&Q&N) to S,T,S +25,T+25
      add 25 to S
   end repeat
   add 25 to T
   put 0 into S
    end repeat
end mouseUp
That will make a 10 x 10 matrix of fields that you can address separately.
You'll probably want to change the size of the fields and I suggest you make a new stack to experiment with.
Just un-select the "focasable" for your labels. You'll probably want to group them as well for scrolling.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: How to blank off some cells in table field

Post by sturgis » Thu Mar 14, 2013 4:56 am

Yep, table field does throw an kink into things once in a while. An array of fields would surely be easier to work with. However, my noggin is starting to work again now that i've rested a bit so here is an ugly but functional (yet bare minimum) example of using linktext in a table grid for this. Not well thought out, but hey it works.

Heres a link to the stack: https://dl.dropbox.com/u/11957935/linktexttest.livecode

It just pops up a field in the center of the card when a link is clicked on, with the field populated with the current text.

The links have their linktext set to cell position (1,1 upper left) so that the data can be shoved back into the right place.

Edit the field, return or enter updates the correct cell.

However. Even though it works.. the simon method is the way to go!

user#606
Posts: 217
Joined: Sun Jan 27, 2008 12:25 pm
Contact:

Re: How to blank off some cells in table field

Post by user#606 » Thu Mar 14, 2013 6:05 pm

Hi,
Thank you both, sturgis and Simon.
I appreciate your effort and contribution, but the cure is worse than the disease.

The saving and loading of a table field was the driver here. It is so easy to do, compared with individual fields.
I accept that the idea was good, but the technicality was flawed.
I have decided to do it the traditional way.

Thank you again, your effort was appreciated.

Post Reply