I've been looking for a mouseover effect in LiveCode but I haven't got it yet.
I would like to get an effect somewhat like this link:
Creating a Mouseover Fade Effect with jQuery
This was created in jQuery. Can it be applied in LiveCode?
mouseEnter (followed by mouseLeave) is pretty much the equivalent of mouseover in web technologies. LiveCode doesn't have a built-in fade effect, but you can write your own by changing the blendLevel property of an object. For example, add the following script to a button to make it fade out to 80% translucency on mouseEnter (mouseover), and fade back to opaque on mouseLeave:
on mouseEnter
repeat with N = 0 to 80 step 5
set blendLevel of me to N
end repeat
end mouseEnter
on mouseLeave
repeat with N = 80 to 0 step -5
set blendLevel of me to N
end repeat
end mouseLeave
If you don't need the fade-in/out you can accomplish the rollover effect without scripting. Simply import the two images, then set the icon property of a button to the id of one image and the hoverIcon property of the same button to id of the other image.
In terms of scripting rollover effects, Scott's answer is spot-on—you can use the mouseEnter and mouseLeave messages to create whatever visual change you want. If you need the fade-in/out effect this will do it:
-Create a new button, make it transparent, showName off, borders off.
-Import your two images. Let's say they are named image1 and image2.
-Set the script of the button to the following:
on mouseEnter
set the effectRate to 500
lock screen for visual effect
set the icon of me to "image2"
unlock screen with visual effect dissolve
end mouseEnter
on mouseLeave
set the effectRate to 500
lock screen for visual effect
set the icon of me to "image1"
unlock screen with visual effect dissolve
end mouseLeave
This creates an effect almost precisely like the one in the link you provided. You can change the rate of the dissolve effect by changing the effectRate; higher rate for slower dissolve, lower rate for faster dissolve. (The effectRate is in milliseconds.)
on mousewithin
put random(1000)
end mousewithin
Related
A Button in Godot can only hold a single line of text. I can overcome this limitation by placing RichTextLabel node inside the button.
Now the button can contain more lines of text, but its height doesn't change automatically when more lines are needed. Instead the text just overflows:
Of course I can manually resize the button to be higher, but I'd like this to happen automatically depending on the amount of text inside. Specifically, I'm generating a list of these buttons programmatically and showing inside a HBoxContainer, with some buttons having longer and other shorter text.
Is there a way to achieve this with Godot layout tools?
Since the Button is in a Container, it is in control of its rect_size. The best we can do is specify a rect_min_size. There is no layout preset to have a Control depend on children Control. So, to answer the question as posted: No, we cannot achieve this with Godot layout tools. We need some scripting.
We need to set the rect_min_size for the Button depending on the RichTextLabel. We can ask it for the height of its content with get_content_height. Which also means we need to set the width beforehand. However, it will not update right away when we set the text (we are going to use yield).
Apparently you don't want the Container to control the height of the Button. If that is the case, I think you can remove all the flags from size_flags_vertical.
About the width, since as I was explaining before we need to set the width to get the height… I suggest you let the Container expand the width of the Button as much a posible. Which mean setting both the Fill and Expand flags on size_flags_horizontal.
Then, with the RichTextLabel properly set to take as much width of the parent Button as possible, you can read it height, and use it to set the height of the rect_min_size of the Button.
One more thing: you want to set the mouse filter of the RichTextLabel to Ignore or Pass, or it will prevent pressing the Button.
This is the code I came up with:
var b := Button.new()
b.size_flags_vertical = 0
b.size_flags_horizontal = SIZE_EXPAND_FILL
add_child(b)
var l := RichTextLabel.new()
l.mouse_filter = Control.MOUSE_FILTER_IGNORE
l.set_anchors_and_margins_preset(Control.PRESET_WIDE)
l.text = "Some\nMultiline\nText"
b.add_child(l)
yield(get_tree(), "idle_frame")
b.rect_min_size.y = l.get_content_height()
I'd like this to happen automatically depending on the amount of text inside
Sadly changing the text does not resize, nor change the minimum size of the RichTextLabel. And RichTextLabel does not have a "text changed" signal. Nor "bbcode text changed" signal. Furthermore, it might not be feasible to intercept these properties (see append_bbcode et.al). It is proabaly easier to do with a regular Label.
Anyway, what I'm going to suggest for this is to make a Control that wraps the RichTextLabel, offers whatever interface you actually need, and in any method where you change the text, afterwards, you do the equivalent of this:
yield(get_tree(), "idle_frame")
b.rect_min_size.y = l.get_content_height()
(Godot 3.x)
Without using scripting, it is also possible to achieve the same goal by wrapping both nodes as sibilings within a container, for example a MarginContainer. Enable the RichTextLabel's fit_content_height property, which will result in the label expanding the container's area as much as necessary, which will in turn resize the Button.
Summary: I'm having a big problem with layout design in my project... I want to set it up in fullscreen mode, but I can only set it in a specify resolution, because of that, when I click to maximize my program, it goes like image #2... I tried to anchor buttons in "Top,Left,Bottom,Right" but the mess is bigger (image #3).
What I need: I want to make a single layout for a fullscreen mode in any screen resolution...
Image 1 below
Image 2 below
Image 3 below
When I use fill mode...
If I understand right and you want everything to stretch when you resize your form then you should dock your tablelayoutpanel (fill) and the same with your buttons.
When I start up my PyQt GUI, the focus immediately goes to the text box.
I want there to be no focus on any of the buttons at the start of the program, especially not the text box.
Is there a way to remove the focus entirely or at least move the focus to a button or something?
Thanks
clearFocus() seems to work after a certain amount of delay after the window is visible. I also used setFocus() on the QMainWindow and then the textedit field lost focus.
Create a button with dimensions 0 wide by 0 high.
Set it as the default button and also early in the tab order before the other controlls that except focus; but note that it will be triggered if the user presses ENTER in some edit controls.
Call self.ui.yourbutton.setFocus() if desired for example after restore from minimized
I'm curious as to whether there is a method for what I want to do. For instance: Let's say I have an SVG and decide to animate it, and every time it's run, the stroke-offset I have set is randomized, and infinite.
An example of the stroke animation is this, minus the randomization:
https://css-tricks.com/wp-content/uploads/2014/02/animate-stroke.gif
Now. If I want to open that SVG and print it (Pressing Ctrl/Cmd + P) straight from the desktop (not within any other application)— is it possible for the SVG to run it's randomization when I print it?
Again, I understand some may comment—"Print is dead, what are you doing..." But this is out of curiosity.
Print isn't dead. It just sat back and watched as we fiddled with our new toys.
Using Javascript, you can detect when printing is happening by adding a listener to the beforeprint event. See: Detecting browser print event
Then stop the animation (by adding a class, for example), and set your stroke-dashoffset to whatever you want.
Then reset everything back afterwards by listening for the afterprint event.
Greetings.
I have to make a draggable MFC dialog window, which has a background - used that: http://www.codeproject.com/KB/graphics/picturewindow.aspx - and has several picturebox controls. I have tried two approaches, and while they do work, they have some problems.
First approach is "Manual" - on the LBUTTONDOWN message I check if it;s on a clean area of my window, and set a flag variable. On MOUSEMOVE, the flag is checked and if it's set, a MoveWindow function is called, and then, Invalidate(1). On LBUTTONUP, flag is unset.
This approach works correctly and redraws as needed, but is somehow very slow - if I'm moving the cursor too fast, the window falls behing and isn't dragged, as cursor's not over the window anymore.
The second approach is "Automatic" - I just call
DefWindowProc(WM_SYSCOMMAND, SC_MOVE+2,MAKELPARAM(point.x,point.y));
on LBUTTONDOWN, and it handles the rest, it's quick and never fall behind, but when I drag it over screen's edge ( so that some part of the window gets invisible), when I drag it back, all the controls get invisible and are not refreshed, background is okay. I suppose that's because Invalidate() isn't called during movement that way, as I actually call it after calling DefWindowProc() and so, everything is refreshed properly when I depress the button.
What should I do to improve either of those solutions? I need it both fast and correct. I may have not provided some required information, I'll add it is need arise.
Thanks in advance.
Solved the problem, by modifying the second way. I added a total redraw to the OnPaint(), and to get rid of flicker, I only redraw durng dragging, by using a flag variable.