Toggle Attribute

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|

Toggle Attribute

L.W.
Hi,

is there a way to have a feature on map and when I press/click/hover on
it that some event is raised?

Primary I want to toggle an attribute field true/false.

I than will e.g. display a special symbol(layer) to an other feature.

Example: Feature A has a foreign key to Feaure B, when B is hovered then
A's symbol should be yellow instead of green.

Regards

_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
Reply | Threaded
Open this post in threaded view
|

Re: Toggle Attribute

thayeray
Date: Sat, 21 Nov 2020 11:51:50 +0100
From: "L.W." <[hidden email]>
Subject: [Qgis-user] Toggle Attribute
Message-ID: <[hidden email]>
Content-Type: text/plain; charset=utf-8; format=flowed

Hi,

is there a way to have a feature on map and when I press/click/hover on
it that some event is raised?

Primary I want to toggle an attribute field true/false.

I than will e.g. display a special symbol(layer) to an other feature.

Example: Feature A has a foreign key to Feaure B, when B is hovered then
A's symbol should be yellow instead of green.

Regards






_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
Reply | Threaded
Open this post in threaded view
|

Re: Toggle Attribute

berndv.
In reply to this post by L.W.
I had a similiar use case, see here:
https://gis.stackexchange.com/q/322544/8202

Unfortunately, I just noticed the answer on my post then right now, so I
did not dig any deeper.

Basic thing is, that you can establish a "connection" between two layers
by an "aggregate" function.

But how to use that to change the style on e.g. a hover, is still beyond
my capabilities, but I'm prettey sure there  is some clever way to
accomplish that. Sadly, I'm not that clever. Maybe something with rule
based style?

Cheers,

Bernd

On 21.11.20 11:51, L.W. wrote:

> Hi,
>
> is there a way to have a feature on map and when I press/click/hover on
> it that some event is raised?
>
> Primary I want to toggle an attribute field true/false.
>
> I than will e.g. display a special symbol(layer) to an other feature.
>
> Example: Feature A has a foreign key to Feaure B, when B is hovered then
> A's symbol should be yellow instead of green.
>
> Regards
>
> _______________________________________________
> Qgis-user mailing list
> [hidden email]
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
Reply | Threaded
Open this post in threaded view
|

Re: Toggle Attribute

djes
Can't you just use layer's actions?

djes

Le dim. 22 nov. 2020 à 08:43, Bernd Vogelgesang <[hidden email]> a écrit :
I had a similiar use case, see here:
https://gis.stackexchange.com/q/322544/8202

Unfortunately, I just noticed the answer on my post then right now, so I
did not dig any deeper.

Basic thing is, that you can establish a "connection" between two layers
by an "aggregate" function.

But how to use that to change the style on e.g. a hover, is still beyond
my capabilities, but I'm prettey sure there  is some clever way to
accomplish that. Sadly, I'm not that clever. Maybe something with rule
based style?

Cheers,

Bernd

On 21.11.20 11:51, L.W. wrote:
> Hi,
>
> is there a way to have a feature on map and when I press/click/hover on
> it that some event is raised?
>
> Primary I want to toggle an attribute field true/false.
>
> I than will e.g. display a special symbol(layer) to an other feature.
>
> Example: Feature A has a foreign key to Feaure B, when B is hovered then
> A's symbol should be yellow instead of green.
>
> Regards
>
> _______________________________________________
> Qgis-user mailing list
> [hidden email]
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
Reply | Threaded
Open this post in threaded view
|

Re: Toggle Attribute

berndv.
if you would be so kind to explain the "just" part of your proposal?

On 22.11.20 15:56, Jésahel Benoist wrote:

> Can't you just use layer's actions?
>
> djes
>
> Le dim. 22 nov. 2020 à 08:43, Bernd Vogelgesang <[hidden email]>
> a écrit :
>
>> I had a similiar use case, see here:
>> https://gis.stackexchange.com/q/322544/8202
>>
>> Unfortunately, I just noticed the answer on my post then right now, so I
>> did not dig any deeper.
>>
>> Basic thing is, that you can establish a "connection" between two layers
>> by an "aggregate" function.
>>
>> But how to use that to change the style on e.g. a hover, is still beyond
>> my capabilities, but I'm prettey sure there  is some clever way to
>> accomplish that. Sadly, I'm not that clever. Maybe something with rule
>> based style?
>>
>> Cheers,
>>
>> Bernd
>>
>> On 21.11.20 11:51, L.W. wrote:
>>> Hi,
>>>
>>> is there a way to have a feature on map and when I press/click/hover on
>>> it that some event is raised?
>>>
>>> Primary I want to toggle an attribute field true/false.
>>>
>>> I than will e.g. display a special symbol(layer) to an other feature.
>>>
>>> Example: Feature A has a foreign key to Feaure B, when B is hovered then
>>> A's symbol should be yellow instead of green.
>>>
>>> Regards
>>>
>>> _______________________________________________
>>> Qgis-user mailing list
>>> [hidden email]
>>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
>>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
>> _______________________________________________
>> Qgis-user mailing list
>> [hidden email]
>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
>>
_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
Reply | Threaded
Open this post in threaded view
|

Re: Toggle Attribute

djes
The actions are a standard way of acting on graphical objects, so for me it would be the first thing to try. Did you ?

Le dim. 22 nov. 2020 à 20:01, Bernd Vogelgesang <[hidden email]> a écrit :
if you would be so kind to explain the "just" part of your proposal?



_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
Reply | Threaded
Open this post in threaded view
|

Re: Toggle Attribute

L.W.

I did not knew before ... I tried a bit and I can not found someting for e.g. onHover (on map over feature) to possible change a attributes value or set some temporarly variable to set a style.


Am 22.11.2020 um 20:40 schrieb Jésahel Benoist:
The actions are a standard way of acting on graphical objects, so for me it would be the first thing to try. Did you ?

Le dim. 22 nov. 2020 à 20:01, Bernd Vogelgesang <[hidden email]> a écrit :
if you would be so kind to explain the "just" part of your proposal?



_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
Reply | Threaded
Open this post in threaded view
|

Re: Toggle Attribute

Richard Duivenvoorde
In reply to this post by djes
On 11/22/20 8:40 PM, Jésahel Benoist wrote:
> The actions are a standard way of acting on graphical objects, so for me it would be the first thing to try. Did you ?
>
> Le dim. 22 nov. 2020 à 20:01, Bernd Vogelgesang <[hidden email] <mailto:[hidden email]>> a écrit :
>
>     if you would be so kind to explain the "just" part of your proposal?

I think in the User lists it is always good to add a link to some documentation about a QGIS-term. In this case 'actions' kan be a normal word, but (advanced) users maybe (or not) know that it is also something you can use to 'do something in QGIS upon a click on a feature'.

Some documentation here:
https://docs.qgis.org/testing/en/docs/user_manual/working_with_vector/vector_properties.html#actions-menu
(or do a search on 'actions' in the QGIS docs site).
Tip: go to vector layer properties, 'Actions' tab, and hit 'Create Default Actions' button. You will get all kind of examples.

About original post: I do not think we have an Action on hover (plz correct me if I'm wrong), but to run some (PyQGIS) python code is doable.
With PyQGIS you can search for features in other layers, and maybe 'select' these on click in the other layer (or change attribute, though I'm not sure how to change it back then... )

Acutally this sounds like nice functionality for layers which have relations... I'm not so experienced with relations in layers.

If you worked out a way to do this, plz let us know :-)

Regards,

Richard

_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
Reply | Threaded
Open this post in threaded view
|

Re: Toggle Attribute

L.W.
I tried a little bit with "actions" but - I think you're right - there
is no onHover.

anyway, I found a much more comfortable solution for the moment.

I add the simple term "OR is_selected()" in the if clause for my symbol
to show the changed color (in my case I draw a line between two points)
and it worked like a charme.

But, this is without the option to e.g. display a messagebox or someting
like that with additional informations of the feature (I know about map
hints/tips (I do not know the right translation).

Yes you could made an action for that, but my goal was to show this on
hover, but click is oooookay.

For X-Mas my wish in relation to QGIS is a hover event ... on feature on
map and on symbols. ;-)

Thanks for helping to everyone.


PS: Do I have to implement a Plugin to have a dockable window for
showing infos non modal on per action selected features?


Am 23.11.2020 um 09:40 schrieb Richard Duivenvoorde:

> On 11/22/20 8:40 PM, Jésahel Benoist wrote:
>> The actions are a standard way of acting on graphical objects, so for me it would be the first thing to try. Did you ?
>>
>> Le dim. 22 nov. 2020 à 20:01, Bernd Vogelgesang <[hidden email] <mailto:[hidden email]>> a écrit :
>>
>>      if you would be so kind to explain the "just" part of your proposal?
> I think in the User lists it is always good to add a link to some documentation about a QGIS-term. In this case 'actions' kan be a normal word, but (advanced) users maybe (or not) know that it is also something you can use to 'do something in QGIS upon a click on a feature'.
>
> Some documentation here:
> https://docs.qgis.org/testing/en/docs/user_manual/working_with_vector/vector_properties.html#actions-menu
> (or do a search on 'actions' in the QGIS docs site).
> Tip: go to vector layer properties, 'Actions' tab, and hit 'Create Default Actions' button. You will get all kind of examples.
>
> About original post: I do not think we have an Action on hover (plz correct me if I'm wrong), but to run some (PyQGIS) python code is doable.
> With PyQGIS you can search for features in other layers, and maybe 'select' these on click in the other layer (or change attribute, though I'm not sure how to change it back then... )
>
> Acutally this sounds like nice functionality for layers which have relations... I'm not so experienced with relations in layers.
>
> If you worked out a way to do this, plz let us know :-)
>
> Regards,
>
> Richard
>
_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
Reply | Threaded
Open this post in threaded view
|

Re: Toggle Attribute

L.W.
and there are some disadvantages ... first you have to set the layer
active to which the symbol belongs.

there is no "is_" derivat for "get object info" (i-icon with
mouse-pointer), so nothing happened if the feautre attribute-dialog is
shown, the feature is (different) highlighted but not the same way as
"selected" (by the yellow buttons with mouse-pointer).


Am 23.11.2020 um 10:06 schrieb L.W.:

> I tried a little bit with "actions" but - I think you're right - there
> is no onHover.
>
> anyway, I found a much more comfortable solution for the moment.
>
> I add the simple term "OR is_selected()" in the if clause for my symbol
> to show the changed color (in my case I draw a line between two points)
> and it worked like a charme.
>
> But, this is without the option to e.g. display a messagebox or someting
> like that with additional informations of the feature (I know about map
> hints/tips (I do not know the right translation).
>
> Yes you could made an action for that, but my goal was to show this on
> hover, but click is oooookay.
>
> For X-Mas my wish in relation to QGIS is a hover event ... on feature on
> map and on symbols. ;-)
>
> Thanks for helping to everyone.
>
>
> PS: Do I have to implement a Plugin to have a dockable window for
> showing infos non modal on per action selected features?
>
>
> Am 23.11.2020 um 09:40 schrieb Richard Duivenvoorde:
>> On 11/22/20 8:40 PM, Jésahel Benoist wrote:
>>> The actions are a standard way of acting on graphical objects, so
>>> for me it would be the first thing to try. Did you ?
>>>
>>> Le dim. 22 nov. 2020 à 20:01, Bernd Vogelgesang
>>> <[hidden email] <mailto:[hidden email]>> a écrit :
>>>
>>>      if you would be so kind to explain the "just" part of your
>>> proposal?
>> I think in the User lists it is always good to add a link to some
>> documentation about a QGIS-term. In this case 'actions' kan be a
>> normal word, but (advanced) users maybe (or not) know that it is also
>> something you can use to 'do something in QGIS upon a click on a
>> feature'.
>>
>> Some documentation here:
>> https://docs.qgis.org/testing/en/docs/user_manual/working_with_vector/vector_properties.html#actions-menu
>>
>> (or do a search on 'actions' in the QGIS docs site).
>> Tip: go to vector layer properties, 'Actions' tab, and hit 'Create
>> Default Actions' button. You will get all kind of examples.
>>
>> About original post: I do not think we have an Action on hover (plz
>> correct me if I'm wrong), but to run some (PyQGIS) python code is
>> doable.
>> With PyQGIS you can search for features in other layers, and maybe
>> 'select' these on click in the other layer (or change attribute,
>> though I'm not sure how to change it back then... )
>>
>> Acutally this sounds like nice functionality for layers which have
>> relations... I'm not so experienced with relations in layers.
>>
>> If you worked out a way to do this, plz let us know :-)
>>
>> Regards,
>>
>> Richard
>>
> _______________________________________________
> Qgis-user mailing list
> [hidden email]
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
Reply | Threaded
Open this post in threaded view
|

Re: Toggle Attribute

berndv.
other ideas after my third coffee:

Maybe you could try with a virtual layer. I'm successfully working with
them to show me the status of to be controlled items with a
geometry-less maintenance-table. But I'm pretty confident that the same
logic would work with two geometry layers

If there was the possibility to query for that is_selected() you found,
it could be possible to just show the requested item and be otherwise
invisible. I will investigate later.

Drawback on Virtual layers is, that they seem to be not very performant,
but maybe my queries are just inefficient crap, who knows.

On 23.11.20 10:29, L.W. wrote:

> and there are some disadvantages ... first you have to set the layer
> active to which the symbol belongs.
>
> there is no "is_" derivat for "get object info" (i-icon with
> mouse-pointer), so nothing happened if the feautre attribute-dialog is
> shown, the feature is (different) highlighted but not the same way as
> "selected" (by the yellow buttons with mouse-pointer).
>
>
> Am 23.11.2020 um 10:06 schrieb L.W.:
>> I tried a little bit with "actions" but - I think you're right - there
>> is no onHover.
>>
>> anyway, I found a much more comfortable solution for the moment.
>>
>> I add the simple term "OR is_selected()" in the if clause for my symbol
>> to show the changed color (in my case I draw a line between two points)
>> and it worked like a charme.
>>
>> But, this is without the option to e.g. display a messagebox or someting
>> like that with additional informations of the feature (I know about map
>> hints/tips (I do not know the right translation).
>>
>> Yes you could made an action for that, but my goal was to show this on
>> hover, but click is oooookay.
>>
>> For X-Mas my wish in relation to QGIS is a hover event ... on feature on
>> map and on symbols. ;-)
>>
>> Thanks for helping to everyone.
>>
>>
>> PS: Do I have to implement a Plugin to have a dockable window for
>> showing infos non modal on per action selected features?
>>
>>
>> Am 23.11.2020 um 09:40 schrieb Richard Duivenvoorde:
>>> On 11/22/20 8:40 PM, Jésahel Benoist wrote:
>>>> The actions are a standard way of acting on graphical objects, so
>>>> for me it would be the first thing to try. Did you ?
>>>>
>>>> Le dim. 22 nov. 2020 à 20:01, Bernd Vogelgesang
>>>> <[hidden email] <mailto:[hidden email]>> a écrit :
>>>>
>>>>      if you would be so kind to explain the "just" part of your
>>>> proposal?
>>> I think in the User lists it is always good to add a link to some
>>> documentation about a QGIS-term. In this case 'actions' kan be a
>>> normal word, but (advanced) users maybe (or not) know that it is also
>>> something you can use to 'do something in QGIS upon a click on a
>>> feature'.
>>>
>>> Some documentation here:
>>> https://docs.qgis.org/testing/en/docs/user_manual/working_with_vector/vector_properties.html#actions-menu
>>>
>>>
>>> (or do a search on 'actions' in the QGIS docs site).
>>> Tip: go to vector layer properties, 'Actions' tab, and hit 'Create
>>> Default Actions' button. You will get all kind of examples.
>>>
>>> About original post: I do not think we have an Action on hover (plz
>>> correct me if I'm wrong), but to run some (PyQGIS) python code is
>>> doable.
>>> With PyQGIS you can search for features in other layers, and maybe
>>> 'select' these on click in the other layer (or change attribute,
>>> though I'm not sure how to change it back then... )
>>>
>>> Acutally this sounds like nice functionality for layers which have
>>> relations... I'm not so experienced with relations in layers.
>>>
>>> If you worked out a way to do this, plz let us know :-)
>>>
>>> Regards,
>>>
>>> Richard
>>>
>> _______________________________________________
>> Qgis-user mailing list
>> [hidden email]
>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
> _______________________________________________
> Qgis-user mailing list
> [hidden email]
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
Reply | Threaded
Open this post in threaded view
|

Re: Toggle Attribute

Mike Flannigan-2
In reply to this post by L.W.

On 10/26/2014 I asked my first question in this forum:

Coordinate Capture plugin allows one to click on the map, hit
the "Copy to clipboard" button, and then use the lat/long on
the clipboard. I want something similar, but I want to
skip the "Copy to clipboard" button. Ideally I want to
click on the map and it copies the lat/long to the clipboard,
executes an external script, and puts the result on the map
next to the place clicked. I can skip the last step if that
is too complicated.

Can that be done with "Actions"? Or is the Python Console or
some other means a better way to get this done?



It went unanswered and I have never found a way to execute a
script upon a click.  I've seen others who wanted actions based
on a click or hover, but no clear solutions presented.  It sounds
like you are on to something below.


Mike


On 11/23/20 5:24 AM, [hidden email] wrote:

> I tried a little bit with "actions" but - I think you're right - there
> is no onHover.
>
> anyway, I found a much more comfortable solution for the moment.
>
> I add the simple term "OR is_selected()" in the if clause for my symbol
> to show the changed color (in my case I draw a line between two points)
> and it worked like a charme.
>
> But, this is without the option to e.g. display a messagebox or someting
> like that with additional informations of the feature (I know about map
> hints/tips (I do not know the right translation).
>
> Yes you could made an action for that, but my goal was to show this on
> hover, but click is oooookay.
>
> For X-Mas my wish in relation to QGIS is a hover event ... on feature on
> map and on symbols.;-)
>
> Thanks for helping to everyone.
>


_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
Reply | Threaded
Open this post in threaded view
|

Re: Toggle Attribute

Jorge Gustavo Rocha-3

Hi Mike,

Just create an action with something like this to see it in action:

https://www.google.pt/maps/@[% @click_x %],[% @click_y %]

This will open google maps at the place you clicked. If you want to get something from the action called, you have to capture its output (and return the right value from your script).

As Richard said, start with the default actions and you will see different kinds of things that can be done with actions. Capturing the clicked X,Y is straight forward.

Jorge

Às 13:22 de 23/11/20, Mike Flannigan escreveu:

On 10/26/2014 I asked my first question in this forum:

Coordinate Capture plugin allows one to click on the map, hit
the "Copy to clipboard" button, and then use the lat/long on
the clipboard. I want something similar, but I want to
skip the "Copy to clipboard" button. Ideally I want to
click on the map and it copies the lat/long to the clipboard,
executes an external script, and puts the result on the map
next to the place clicked. I can skip the last step if that
is too complicated.

Can that be done with "Actions"? Or is the Python Console or
some other means a better way to get this done?



It went unanswered and I have never found a way to execute a
script upon a click.  I've seen others who wanted actions based
on a click or hover, but no clear solutions presented.  It sounds
like you are on to something below.


Mike


On 11/23/20 5:24 AM, [hidden email] wrote:
I tried a little bit with "actions" but - I think you're right - there
is no onHover.

anyway, I found a much more comfortable solution for the moment.

I add the simple term "OR is_selected()" in the if clause for my symbol
to show the changed color (in my case I draw a line between two points)
and it worked like a charme.

But, this is without the option to e.g. display a messagebox or someting
like that with additional informations of the feature (I know about map
hints/tips (I do not know the right translation).

Yes you could made an action for that, but my goal was to show this on
hover, but click is oooookay.

For X-Mas my wish in relation to QGIS is a hover event ... on feature on
map and on symbols.;-)

Thanks for helping to everyone.



_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
--
Email Signature
Logo
Geomaster
Jorge Gustavo Rocha | Software Engineer
e: [hidden email] | m: +351 910 333 888
g: 41.54094,-8.40490 | v: 510 906 109
a: Rua António Cândido Pinto, 67, 4715-400 Braga

_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
Reply | Threaded
Open this post in threaded view
|

Re: Toggle Attribute

L.W.

Implementation:

Starting position:

Two attribute tables with geodata and attributes, linked with each other in the layer properties dialog.
When you click on an object in the map, the corresponding line to the second object should be drawn.
If you click again, nothing more may be drawn.
If object B is set so that the lines should be displayed, then all objects A should display the line regardless of a selection.

Symbol code:

Geometry generator -> LineString

if ("tab2_show_lines" = true OR is_selected () OR "tab1_hv",
make_line (make_point ("x1", "y1"), make_point ("x2", "y2")), '')



Action Script -> Layer Properties -> Actions -> Add New -> Python



Python code:

from qgis.utils import iface

layer_id = '[% @ layer_id%]'
layer_obj = QgsProject (). instance (). mapLayer (layer_id)

fid = [% $ id%]
hv = False if "[% hv%]" == 'false' else True

# QtWidgets.QMessageBox.information (None, "Clicked coords", "layer: [% @layer_id%] \ ncoords: ([% @click_x%], [% @click_y%])")
# QtWidgets.QMessageBox.information (None, "fld", str (fld) + "" + str (hv))

layer_obj.startEditing ()
layer_obj.changeAttributeValue (fid, fld, not hv)
layer_obj.commitChanges ()



---



Cons / Problems / Known Limitations

Action:

Just click, no hover
Action can only be displayed via a combination button, not as a separate button
Difficult to write action script (many clicks to get to the editor)
The layer with the Actionscript must be active / selected
You always have to select the action separately before clicking


Symbol:

Line not visible if the source object is not in the view (target object does not matter), source / target connected by a link


Limitation:

My knowledge of python ;-)

---



Missing features

Edit project variables using the same action as written above



I hope you can learn a little from my gibberish.
Thank you all




Am 23.11.2020 um 15:24 schrieb Jorge Gustavo Rocha:

Hi Mike,

Just create an action with something like this to see it in action:

https://www.google.pt/maps/@[% @click_x %],[% @click_y %]

This will open google maps at the place you clicked. If you want to get something from the action called, you have to capture its output (and return the right value from your script).

As Richard said, start with the default actions and you will see different kinds of things that can be done with actions. Capturing the clicked X,Y is straight forward.

Jorge

Às 13:22 de 23/11/20, Mike Flannigan escreveu:

On 10/26/2014 I asked my first question in this forum:

Coordinate Capture plugin allows one to click on the map, hit
the "Copy to clipboard" button, and then use the lat/long on
the clipboard. I want something similar, but I want to
skip the "Copy to clipboard" button. Ideally I want to
click on the map and it copies the lat/long to the clipboard,
executes an external script, and puts the result on the map
next to the place clicked. I can skip the last step if that
is too complicated.

Can that be done with "Actions"? Or is the Python Console or
some other means a better way to get this done?



It went unanswered and I have never found a way to execute a
script upon a click.  I've seen others who wanted actions based
on a click or hover, but no clear solutions presented.  It sounds
like you are on to something below.


Mike


On 11/23/20 5:24 AM, [hidden email] wrote:
I tried a little bit with "actions" but - I think you're right - there
is no onHover.

anyway, I found a much more comfortable solution for the moment.

I add the simple term "OR is_selected()" in the if clause for my symbol
to show the changed color (in my case I draw a line between two points)
and it worked like a charme.

But, this is without the option to e.g. display a messagebox or someting
like that with additional informations of the feature (I know about map
hints/tips (I do not know the right translation).

Yes you could made an action for that, but my goal was to show this on
hover, but click is oooookay.

For X-Mas my wish in relation to QGIS is a hover event ... on feature on
map and on symbols.;-)

Thanks for helping to everyone.



_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
--
Email Signature
Logo
Geomaster
Jorge Gustavo Rocha | Software Engineer
e: [hidden email] | m: +351 910 333 888
g: 41.54094,-8.40490 | v: 510 906 109
a: Rua António Cândido Pinto, 67, 4715-400 Braga

_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
Reply | Threaded
Open this post in threaded view
|

Re: Toggle Attribute

Mike Flannigan-2
In reply to this post by L.W.

Thank you.  I did get an Action to operate today.  My action also
uses a Google Maps link.

I can click on "Identify Features", which opens a "Identify Results"
panel.  Then I can click on a feature in that layer, open Actions
in the "Identify Results" panel, and click on the action, which
runs the action.

Now I'm trying to make the action more accessible.  Am I correct
in my assumption that the button just to the right of "Identify Features"
should list my Action in the dropdown list?  So list stuff like this:
http://www.mflan.com/temp/action1.jpg
Figure 5 was taken from:
https://www.geodose.com/2018/04/qgis-tutorial-how-to-create-action.html

When I click on that little black triangle on the button just to the right
of "Identify Features" it shows an empty, white box.  When I click on the
button is doesn't do anything.  When I hover over the button it says
"no action selected".

Ideally I would like for the action to run if I just click on the feature.



Mike


On 11/23/20 2:00 PM, [hidden email] wrote:

> Hi Mike,
>
> Just create an action with something like this to see it in action:
>
> https://www.google.pt/maps/@[% @click_x %],[% @click_y %]
>
> This will open google maps at the place you clicked. If you want to get
> something from the action called, you have to capture its output (and
> return the right value from your script).
>
> As Richard said, start with the default actions and you will see
> different kinds of things that can be done with actions. Capturing the
> clicked X,Y is straight forward.
>
> Jorge


_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
Reply | Threaded
Open this post in threaded view
|

Re: Toggle Attribute

Richard Duivenvoorde
Hi Mike,

I did some fiddling with the 'Create default actions' that you can load.

One thing that was not obvious to me, is that you need to set the 'Action Scope'. So be sure it has 'Feature Scope'(or Canvas scope?) if you want to click somewhere in the mapcanvas.

With me selecting one of the possible actions in the Actions button in the toolbar makes it color change from blue to green.

Then there is the option to set some kind of order in the 'Actions'-list of the layer.

For what I see there is no need to use the identify tool. Only if you want the actions to show up in the Identify Results as a clickable Actions button (I think(!) it has to do with the 'Field'-scope).

But it's not very clear to me how this all works together to be honest.
There is some doc here:

https://docs.qgis.org/testing/en/docs/user_manual/working_with_vector/vector_properties.html#actions-properties

There is also a 'lesson' in the Training Manual:

https://docs.qgis.org/testing/en/docs/training_manual/create_vector_data/actions.html?highlight=actions

HTH & Regards,

Richard Duivenvoorde



On 11/24/20 2:21 AM, Mike Flannigan wrote:

>
> Thank you.  I did get an Action to operate today.  My action also
> uses a Google Maps link.
>
> I can click on "Identify Features", which opens a "Identify Results"
> panel.  Then I can click on a feature in that layer, open Actions
> in the "Identify Results" panel, and click on the action, which
> runs the action.
>
> Now I'm trying to make the action more accessible.  Am I correct
> in my assumption that the button just to the right of "Identify Features"
> should list my Action in the dropdown list?  So list stuff like this:
> http://www.mflan.com/temp/action1.jpg
> Figure 5 was taken from:
> https://www.geodose.com/2018/04/qgis-tutorial-how-to-create-action.html
>
> When I click on that little black triangle on the button just to the right
> of "Identify Features" it shows an empty, white box.  When I click on the
> button is doesn't do anything.  When I hover over the button it says
> "no action selected".
>
> Ideally I would like for the action to run if I just click on the feature.
>
>
>
> Mike
>
>
> On 11/23/20 2:00 PM, [hidden email] wrote:
>> Hi Mike,
>>
>> Just create an action with something like this to see it in action:
>>
>> https://www.google.pt/maps/@[% @click_x %],[% @click_y %]
>>
>> This will open google maps at the place you clicked. If you want to get
>> something from the action called, you have to capture its output (and
>> return the right value from your script).
>>
>> As Richard said, start with the default actions and you will see
>> different kinds of things that can be done with actions. Capturing the
>> clicked X,Y is straight forward.
>>
>> Jorge
>
>
> _______________________________________________
> Qgis-user mailing list
> [hidden email]
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user