It is currently October 26th, 2021, 10:47 am

Mouse up action after dragging - drag release action

Help with creating, editing & fixing problems with skins
User avatar
Edhel
Posts: 36
Joined: February 18th, 2014, 4:41 pm

Re: Mouse up action after dragging - drag release action

Post by Edhel »

death.crafter wrote: September 15th, 2021, 4:53 pm Ohh, then use move bang to move the skin.

And leftmouseupaction should be used in the measure and not the meter.

But still, I would just make a measure that calculates the position of a grid according to current skin x and y, then make a measure for moving the skin to that position. If you know lua then the job would be far lot easier.

Currently I can't provide an example of what I am saying because I broke my pc and I don't know when will it be back but once it's back I will provide an example.
That is exactly what I already have. And for some reason, the skin doesn't move. See my code:

Code: Select all

[Rainmeter]
Update=-1

[Variables]
GridSize=80
MyXPos=0
MyYPos=0

;========== Measures

[MeasureMouse]
Measure=Plugin
Plugin=Mouse
DynamicVariables=1
RelativeToSkin=0
LeftMouseDownAction=[!Log "Old coordinates [MeasureX] [MeasureY]"]
LeftMouseUpAction=[!CommandMeasure MeasureMouse "Stop"][!UpdateMeasure "MeasureX"][!UpdateMeasure "MeasureY"][!Log "New coordinates [MeasureX] [MeasureY]"][!UpdateMeasure "Mover"]

[MeasureX]
Measure=Calc
Formula=(Floor(#CURRENTCONFIGX#/#GridSize#)*#GridSize#)
DynamicVariables=1
OnUpdateAction=[!SetVariable "MyXPos" [MeasureX]]

[MeasureY]
Measure=Calc
Formula=(Floor(#CURRENTCONFIGY#/#GridSize#)*#GridSize#)
DynamicVariables=1
OnUpdateAction=[!SetVariable "MyYPos" [MeasureY]]


[Mover]
Measure=Calc
Formula=0
DynamicVariables=1
OnUpdateAction=[!Move [MeasureX] [MeasureY]] [!Log "I moved to [MeasureX] [MeasureY]"]


;========== Meter

[RoundBase]
Meter=Roundline
MeterStyle=Round
LineColor=60,180,60
X=0
Y=0
W=#GridSize#
H=#GridSize#
LineStart=0
LineLength=(#GridSize# / 2)
StartAngle=(Rad(0))
RotationAngle=(Rad(360))
Solid=1
Antialias=1
That is bad situation, hopefully your PC will be back soon
User avatar
eclectic-tech
Rainmeter Sage
Posts: 4438
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Mouse up action after dragging - drag release action

Post by eclectic-tech »

You need to set the skin update rate in the [Rainmeter] to anything other than "-1". This will update the skin with your new position.

Using "-1" has it's place, but not in your scheme; with that setting the skin never updates until you use the !Update bang. However, you are using 'OnUpdateAction' to move the skin, so if you use an '!Update' bang in your 'OnUpdateAction' you will create an endless loop and crash Rainmeter.

The code can be as streamlined as this:

Code: Select all

[Rainmeter]
Update=1000

[Variables]
GridSize=80

;========== Measures

[MeasureX]
Measure=Calc
Formula=(Floor(#CurrentConfigX#/#GridSize#)*#GridSize#)
DynamicVariables=1

[MeasureY]
Measure=Calc
Formula=(Floor(#CurrentConfigY#/#GridSize#)*#GridSize#)
DynamicVariables=1
OnUpdateAction=[!Move "[MeasureX]" "[MeasureY]"]

;========== Meter

[RoundBase]
Meter=Roundline
MeterStyle=Round
LineColor=60,180,60
X=0
Y=0
W=#GridSize#
H=#GridSize#
LineStart=0
LineLength=(#GridSize# / 2)
StartAngle=(Rad(0))
RotationAngle=(Rad(360))
Solid=1
Antialias=1
DynamicVariables=1
To reduce the time it takes to see the skin snap to your grid, decrease the Update=1000 in the [Rainmeter] section.
User avatar
Edhel
Posts: 36
Joined: February 18th, 2014, 4:41 pm

Re: Mouse up action after dragging - drag release action

Post by Edhel »

eclectic-tech wrote: September 16th, 2021, 11:02 pm You need to set the skin update rate in the [Rainmeter] to anything other than "-1". This will update the skin with your new position.

Using "-1" has it's place, but not in your scheme; with that setting the skin never updates until you use the !Update bang. However, you are using 'OnUpdateAction' to move the skin, so if you use an '!Update' bang in your 'OnUpdateAction' you will create an endless loop and crash Rainmeter.

The code can be as streamlined as this...
Thank you for your input but I don't think that is the right solution. Sure, the skin moves within a second (or shorter period of time) but what if I have a skin I want to refresh every 15 minutes (like news feeds) hour (weather forecast) or just once a day?
The infinite loop can be actually avoided by pausing the measure but it still doesn't solve the issue.

What I don't understand is why the skin gets aligned to the grid when I click the skin but not when I release it after dragging. (With Update=-1 and no [!Update] bang.) It makes me think whether that might be some strange behavior in the Mouse plugin. I am no expert in it but it seams like LeftMouseUpAction in the Mouse plugin after dragging does trigger the event first (release button) and then it actually releases the dragged skin in the original place it was moved to. Eg Release skin on coordinates x1, y1 => LeftMouseUpAction => Recalculate the position => Move the skin to the new coordinates x2, y2 => Actually release the skin on the coordinates x1, y1...
Or there is some error in my code I can't see...
User avatar
eclectic-tech
Rainmeter Sage
Posts: 4438
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Mouse up action after dragging - drag release action

Post by eclectic-tech »

This may be a bug causing the need for a second click to show the moved position, but my understanding of using Update=-1 in the Rainmeter section is that Rainmeter will never update the skin. Rainmeter Update
Manual wrote:Using Update=-1 will update the skin only once on load (or on refresh). This is a good option when a skin is strictly controlled by mouse actions, like an application menu or launcher. The skin will never update, but will always react to any mouse actions, where you can use !UpdateMeter and !Redraw to control when the skin is updated and redrawn.
The skin will react to mouse actions, so the skin updates it's current XY grid screen position when it is dragged, but it is not updated until you click again.

You may want to add a post in the 'Bugs & Features' thread and see what the Dev team thinks.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 4438
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Mouse up action after dragging - drag release action

Post by eclectic-tech »

Edhel wrote: September 17th, 2021, 8:42 pm Thank you for your input but I don't think that is the right solution. Sure, the skin moves within a second (or shorter period of time) but what if I have a skin I want to refresh every 15 minutes (like news feeds) hour (weather forecast) or just once a day?
...
The default Update=1000 is what you should use; How Webparser Works. Webparser needs to use that value, it will never automatically update with Update set to -1.

To handle other timings you should use a Time measure and UpdateDivider.
Edhel wrote:The infinite loop can be actually avoided by pausing the measure but it still doesn't solve the issue.
...
How do you pause a measure that is is never being updated?
Edhel wrote:Or there is some error in my code I can't see...
The error is using Update=-1 and expecting the skin to update.
User avatar
Edhel
Posts: 36
Joined: February 18th, 2014, 4:41 pm

Re: Mouse up action after dragging - drag release action

Post by Edhel »

We are getting away from the main issue but I will try to respond to each part...
eclectic-tech wrote: September 18th, 2021, 12:32 pm The default Update=1000 is what you should use; How Webparser Works. Webparser needs to use that value, it will never automatically update with Update set to -1.
The Webparser was just an example. I am not trying to find a solution for some specific webparser skin. I am trying to find a solution for any generic skin. It could be a webparser that downloads data every hour, a clock that updates every minute or a launcher that actually doesn't need to be updated.
eclectic-tech wrote: September 18th, 2021, 12:32 pm How do you pause a measure that is is never being updated?
I start with the MeasureY paused. LeftMouseUpAction has bang to unpause the MeasureY and to update it. The MeasureY has bangs OnUpdateAction to pause itself again, move the skin and then !Update. (Plus writing variables into the log.)
I was able to get the same result as with my original version without the endless loop but the skin still didn't move.

I do agree that setting Update to some value does move the skin within the given time. However, I do not believe it is the right solution. It is also a matter of performance. Every skin that updates has impact on the CPU or RAM usage. I know that Rainmeter impact on system is quite tiny but I believe there is a point in attempting good resources management.

I know I do mistakes and sometimes do things in unnecessary complicated way. That's why I am asking more experienced people here. However, should what you say be true (or intended behavior):
eclectic-tech wrote: September 18th, 2021, 12:32 pm The error is using Update=-1 and expecting the skin to update.
... then the skin should not move after simple click - which it does. So either there is an error in my code neither I nor you have noticed, or there is a bug that allows skin to move using bang !Move with Update set to "-1", or there is a bug that does actually release the dragged skin only after performing all the bangs.

I will took your advice and contact the Devs (or author of the plugin) with possible bug.
User avatar
death.crafter
Posts: 1070
Joined: April 24th, 2021, 8:13 pm

Re: Mouse up action after dragging - drag release action

Post by death.crafter »

Edhel wrote: September 18th, 2021, 6:10 pm ... then the skin should not move after simple click - which it does. So either there is an error in my code neither I nor you have noticed, or there is a bug that allows skin to move using bang !Move with Update set to "-1", or there is a bug that does actually release the dragged skin only after performing all the bangs.

I will took your advice and contact the Devs (or author of the plugin) with possible bug.
You are using !Move with LeftMouseUpAction.
So it woks fine. You'll hav to find other ways for doing what you want to do.
from the Realm of Death
My Current Desktop
User avatar
eclectic-tech
Rainmeter Sage
Posts: 4438
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Mouse up action after dragging - drag release action

Post by eclectic-tech »

From what I can see, an !Update command is ignored by Rainmeter when the skin's [Rainmeter] section is set to Update=-1.

I don't think this is a "bug" because you are telling Rainmeter to never update the skin, so it will still update measures and meter on mouse actions, but will ignore any commands to update the skin.

To accomplish updating a skin's properties (X & Y screen position), while telling Rainmeter to never update the skin, can be done only by refreshing the skin. OnRefreshAction is the last action(s) performed after the skin is loaded or refreshed.

With Update=-1, to move the skin, you are changing SKIN properties (not measures or meters) and you will only see the change after a refresh.

This code will move your meter to the new grid coordinates by writing those values to the variables and refreshing the skin. This may be as CPU intensive as simply using Update=1000 in the skin since you are destroying the entire skin when refreshing it; but it is the only way to see a change in the skin properties when using Update=-1 in the [Rainmeter] section. :x

Your code with the changes to snap to your defined grid.

Code: Select all

[Rainmeter]
Update=-1
OnRefreshAction=[!Move "[#MyXPos]" "[#MyYPos]"][!Log "I moved to [#MyXPos] [#MyYPos]"]

[Variables]
GridSize=80
MyXPos=0
MyYPos=0

;========== Measures

[MeasureMouse]
Measure=Plugin
Plugin=Mouse
DynamicVariables=1
RelativeToSkin=0
LeftMouseDownAction=[!Log "Old coordinates [MeasureX] [MeasureY]"]
LeftMouseUpAction=[!CommandMeasure MeasureMouse "Stop"][!UpdateMeasure "MeasureX"][!UpdateMeasure "MeasureY"][!Log "New coordinates [MeasureX] [MeasureY]"][!Refresh]

[MeasureX]
Measure=Calc
Formula=(Floor(#CURRENTCONFIGX#/#GridSize#)*#GridSize#)
DynamicVariables=1
OnUpdateAction=[!WriteKeyValue Variables "MyXPos" [MeasureX]]

[MeasureY]
Measure=Calc
Formula=(Floor(#CURRENTCONFIGY#/#GridSize#)*#GridSize#)
DynamicVariables=1
OnUpdateAction=[!WriteKeyValue Variables "MyYPos" [MeasureY]]

;========== Meter

[RoundBase]
Meter=Roundline
MeterStyle=Round
LineColor=60,180,60
X=0
Y=0
W=#GridSize#
H=#GridSize#
LineStart=0
LineLength=(#GridSize# / 2)
StartAngle=(Rad(0))
RotationAngle=(Rad(360))
Solid=1
Antialias=1
This was an interesting issue and hopefully this delayed solution will help. :great:
User avatar
Edhel
Posts: 36
Joined: February 18th, 2014, 4:41 pm

Re: Mouse up action after dragging - drag release action

Post by Edhel »

eclectic-tech wrote: September 20th, 2021, 5:19 pm This was an interesting issue and hopefully this delayed solution will help. :great:
I apologize for bothering you all, guys. You have offered some good advice and I will most probably follow them and abandon that Update=-1 idea.
I just don't understand why the skin moves with simple click and not after dragging when everything else is the same... The same skin without any change in code, without refreshing, I drag the skin - it doesn't realign, I click it - it does realign, I drag it - nothing, drag it again - nothing, click it - it realigns... O.O And during all that dragging and clicking, the logs look the same :?