why check box does not move when stack is resized? - livecode

I made a stack that displays lines of text that change their width when the stack is resized.
The Category columns is changing its position on resizing but the check box does not.
What am I missing in the code? What changes have to be made?
See the code in the stack that can be downloaded here:
https://dl.dropboxusercontent.com/u/99863601/Data%20grid%20Form-variable%20line%20height%2Bcheckbox.zip
Thanks in advance.
keram

If I understand what you are trying to achieve here then in your LayoutControl handler make the following change:
-- put the rect of btn "btnCheck" of me into theFieldRect
-- put item 3 of pControlRect - 5 into item 3 of theFieldRect
-- set the rect of btn "btnCheck" of me to theFieldRect
set the left of btn "btnCheck" of me to the right of fld "cat" of me
However I think the resizing of the Cat field is wrong too. Try something like:
on LayoutControl pControlRect
set the right of btn "btnCheck" of me to item 3 of pControlRect-4
set the right of fld "Cat" of me to the left of btn "btnCheck" of me
get the rect of fld "Line" of me
put the left of fld "Cat" of me into item 3 of it
set the rect of fld "Line" of me to it
put the formattedHeight of fld "Line" of me + item 2 of it into item 4 of it
set the rect of fld "Line" of me to it
put item 4 of it into item 4 of pControlRect
set the rect of graphic "Background" of me to pControlRect
end LayoutControl
To edit the LayoutControl script you need to open the datagrid property inspector and click on the Row Behavior... button. This will present the script editor for the behavior of the row template.

Because the DataGrid doesn't have this feature. If you would use the Geometry manager, the GM propeties are not copied from the checkbox in the template to the checkboxes in the actual DG. So, the GM won't work. Perhaps you could write a script of your own that sets the right of all checkboxes to a position relative to the width of the card:
on resizeStack
lock screen
repeat with x = 1 to number of buttons
if the style of btn x is "checkbox" then
set the right of btn x to the width of this cd - 100
end if
end repeat
unlock screen
end resizeStack
Unfortunately, this doesn't work with the datagrid either, because the DG also does some (or a lot) resizing of its own.
It would be much easier to create your own.

Related

PyQt4 tooltip for overlap rect items

In my view, I have 2 rect items , which one of them included in the other.
I want to set a tooltip for both of them, so when mouse is on the common area I'll get the inner tooltip, else, I'll get the outer.
I already saw it's impossible to add 2 tooltips on the same area, but this case is different, because the rects are overlap by one direction ..
rect_item_inner = QtGui.QGraphicsRectItem()
rect_item_outer = QtGui.QGraphicsRectItem()
rect_item_inner.setToolTip("inner data")
rect_item_outer.setToolTip("outer data")

How to increase the size of a checkbox?

I'm trying to increase the size of a checkbox in my Userform.
In the properties tab, I can change the height and the width of the object but it doesn't change the size of the square. I add a picture to explain my issue.
Thank you.
#Portland Runner's comment is a good suggestion. For example, in the click event of the label (using WingDings 2) ...
Option Explicit
Private Sub Label1_Click()
If Label1.Caption = "Q" Then
Label1.Caption = "R"
Else
Label1.Caption = "Q"
End If
End Sub
There are 2 problems with the VBA checkbox:
The size of the square
The size of the caption text
My solutions:
Create a frame in which you put the checkbox object. A frame has the property Zoom. Set that property at whatever value you want. Then change the font size of the button to match the rest of the fonts in the form. The frame doesn't have to have a title, and you can select an invisible border for it. In that way, the user doesn't see it.
For whatever reason, the checkbox's text looks smaller than the rest of the objects, even though it is the same font size. My solution for this was to remove the checkbox's text and add a standard label object to the right.

How do I make an Excel ActiveX label to be transparent ... at runtime?

I want to put a transparent label on top of a sheet in Excel, so that I can take advantage of the MouseMove event of the label to "draw cells" (aka change their fill color and so on) by mouse click / drag / etc. - since I can't do that on the cells per se.
Now everything works just fine, except that I can't make the label transparent at runtime (aka in VBA) ... while by doing exactly the same thing in Design Mode works as expected. Specifically, I have the code (more or less):
Dim MapLabel As OLEObject
On Error Resume Next
Sheet2.OLEObjects("MapLabel").Delete
Set MapLabel = Sheet2.OLEObjects.Add("Forms.Label.1")
MapLabel.name = "MapLabel"
MapLabel.Placement = xlMoveAndSize
MapLabel.Object.Caption = ""
' Problem line below
MapLabel.Object.BackStyle = fmBackStyleTransparent
' Problem line above
MapLabel.Left = Sheet2.cells(2, 6).Left
MapLabel.Top = Sheet2.cells(2, 6).Top
MapLabel.Width = Sheet2.cells(2,6).Width * 10
MapLabel.Height = Sheet2.cells(2,6).Height * 10
So, in words, I first delete the label named 'MapLabel', then recreate it (the above code goes into a "init" Sub). All the code lines except the one marked produce the desired result. The marked one does set the BackStyle property of the label to fmBackStyleTransparent ... but it doesn't actually make the label transparent. This is frustrating, because it's the same approach that works flawlessly at design time!
Do you have a solution to this? I read about solving similar problems by declaring the label as MsForms.Label or as Control, but the sheet object doesn't have those properties, plus, there are far more label properties which can be set using the OLEObject than with the help of MsForms.Label or Control.
All you need to do after this line:
MapLabel.Object.BackStyle = fmBackStyleTransparent
put this line:
ActiveSheet.Shapes(MapLabel.Name).Fill.Transparency = 1
I hope I helped.
P.S. If you need explanation i will edit my answer.
I had the same problem as you but in Word. The solution for me was to do the following:
In design mode:
Right click on the object
Navigate to Switch to automatic form/Image > Wrapping > In front of the text
Add an empty picture to your label

How to prevent change in a listbox selected item when users click and move mouse before mouseup

I am using the following code in a scrolling field. It works fine in both windows and android. The only problem is that the selected item changes as the mouse mouses up and down the list. I would like the original highlighted line to remain highlighted during the scroll and only change if the mouse have not moves move than 11 units(row height is 22) from initial vertical position. How do I modify this code to achieve that?
local lmousev,lvscroll,lscrolling
on mousedown
--If we don't use lscrolling the list will scroll when the mouse hovers over it
put true into lscrolling
--Set the initial vertical position of the cursor
put the mousev into lmousev
--Set the inital position of the vertical scroll
put the dgvscroll of me into lvscroll
end mousedown
on mousemove x,y
if lscrolling=true then --lscrolling is only true after mousedown so no scroll when mouse hovers over
--adjust the scroll position based on the vertical distance that the mouse has moved since mousedown
set the dgvscroll of me to lvscroll -(y - lmousev)
end if
end mousemove
on mouseUp
--stop scrolling when mouse hovers
put false into lscrolling
If abs( the mousev-lmousev)<11 then --If vertival position of mouse has not moved far from vertical position at mousedown
--selectlist command is in the group. It insert list selection into the textbox
selectlist
end if
end mouseUp
on mouserelease
--stop scrolling when mouse is release outside the listbox and there is no mouseup
put false into lscrolling
end mouserelease
The button,textbox and listbox that forms the combobox are grouped.The code to show/hide listbox and add selected to textbox is in the group script as follows:
Additional Info
local ldrop=false
on buttonclick --show/hide the listbox
--Get the name of the group,textbox & listbox.
--Naming convention required:- textboxname=txt & groupName,listboxname=lst & groupname
--Using quote as deliminater allows us to get the groupname from group "groupname"
set the itemdel to quote
put item 2 of the name of me into groupname
put "lst" & groupname into lstName
put "txt" & groupname into txtName
--status of ldrop let us know if the listbox is visible
if ldrop=false then
--show listbox
set the visible of field lstName to true
put true into ldrop
else
--hide listbox
set the visible of field lstName to false
put false into ldrop
end if
end buttonclick
on selectlist
--Get the name of the group,textbox & listbox.
--Naming convention required:- textboxname=txt & groupName,listboxname=lst & groupname
--Using quote as deliminater allows us to get the groupname from group "groupname"
set the itemdel to quote
put item 2 of the name of me into groupname
put "lst" & groupname into lstName
put "txt" & groupname into txtName
put the hilitedLine of field lstName into lhilitedLine
put line lhilitedLine of field lstName into field txtName
set the visible of field lstName to false
put false into ldrop
end selectlist
I think you have to make your own control that acts like a list so that you can control all the messages it sends and receives. You are otherwise stuck with some of those basic functions of LC's built-in controls. seems like you'd need an engine-level tweak to the control.

How to fix variable line height in data grid with SQLite database when using callbacks

I'm working with the data grid with SQLite database using a feature called callbacks as described in this lesson: displaying-large-amounts-of-data
I'd like to make some changes to the sample stack included in that lesson (you can download the stack from the link on the top of that page).
I'd like to display the 'plot' text in the DG instead of the 'Title' of the movie and the plot text should have variable line heights as described in this lesson: how-do-i-create-a-form-with-variable-line-heights
In the sample stack I made these changes:
in the Row Template:
renamed field "Title" to "plot", set the dontWrap to false and changed fixedLineHeight to false
renamed field "ReleaseDate" to "nr"
added:
set the text of field "nr" of me to pDataArray["id"]
in the Row Behavior:
## changed the layoutControl to make space for wrapping of field "plot"
on LayoutControl pControlRect
local theFieldRect
put the rect of me into theFieldRect
set the right of button "Genre" of me to item 3 of theFieldRect
set the right of field "LblGenre" of me to the left of button "Genre" of me
set the right of field "nr" of me to item 3 of theFieldRect
## Expand field "plot"
put the rect of field "plot" of me into theFieldRect
put item 3 of pControlRect - 180 into item 3 of theFieldRect
set the rect of field "plot" of me to theFieldRect
##Now resize field to fit content
put item 2 of theFieldRect \
+ the formattedheight of field "plot" of me - \
the bottommargin of field "plot" of me \
into item 4 of theFieldRect
set the rect of field "plot" of me to theFieldRect
## Now update the bounding rect to match total height you
## want this row to have
put item 4 of theFieldRect into item 4 of pControlRect
set the rect of graphic "Background" of me to pControlRect
end LayoutControl
In the lesson on setting variable line heights it says to turn off the "fixed control height" of the data grid. However when I do that nothing gets displayed and I'm getting a scrip error.
The stack with my changes is here: Databases-callbacks-variable-line-height.zip
(just replace the original stack from the lesson with it; the SQLite database is the same and should be placed in the same folder as the stack).
How to fix this so that the variable line height will work?
I located the problem with fixed control height turned off. The data grid behavior isn't setting the GetDataForLine pLine parameter properly when caching the height for each row. I'll provide a modification you can make to the data grid behavior until a fix is included in LiveCode, but you should probably reconsider your approach. When fixed line height is turned off the data grid has to compute the height of every line prior to displaying the data grid. This takes a loooooong time for the 50,000 record example you are working with.
First, edit the script of the data grid behavior:
edit script of btn "data grid" of stack "revdatagridlibrary"
Next, go to line 3097. Below 3097 add the following line of code:
add 1 to theSequence
The code should now look like this:
repeat for each key theIndex in sDataArray
add 1 to theSequence
## Get height
if sDataArray[theIndex] is NULL then
Save the script. This will save the change in your current version of LiveCode. Be aware that the next time you update LiveCode the change will be lost. I submitted the fix to RunRev, however, so it should be fixed in the next release.
Also, your code that sets the rect of graphic "Background" needs a small change. Right now it won't work if the bottom of the field is higher than the bottom of the "Genre" button. The code should probably be something like this:
put max(item 4 of theFieldRect, the bottom of button "Genre" of me + 4) into item 4 of pControlRect

Resources