<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Infinity Code Forum — Map Input only when Mouse over Map]]></title>
	<link rel="self" href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=1802&amp;type=atom" />
	<updated>2021-07-14T16:57:48Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.infinity-code.com/viewtopic.php?id=1802</id>
		<entry>
			<title type="html"><![CDATA[Re: Map Input only when Mouse over Map]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=7596#p7596" />
			<content type="html"><![CDATA[<p>Something like this (OnlineMapsRawImageTouchForwarder.OnGetTouchCount):<br /></p><div class="codebox"><pre><code>    private int OnGetTouchCount()
    {
        if (target != image.gameObject) return 0;

        int button = 1;
        Vector2 screenPosition = map.control.GetInputPosition();
        IOnlineMapsInteractiveElement interactiveElement = map.control.GetInteractiveElement(screenPosition);
        if (interactiveElement != null)
        {
            button = 0;
        }

#if UNITY_EDITOR
        return Input.GetMouseButton(button) ? 1 : 0;
#else
        if (Input.touchSupported)
        {
            if (Input.touchCount &gt; 0) return Input.touchCount;
        }
        return Input.GetMouseButton(button) ? 1 : 0;
#endif
    }</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2021-07-14T16:57:48Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=7596#p7596</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Map Input only when Mouse over Map]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=7591#p7591" />
			<content type="html"><![CDATA[<p>Thank you very much for the video. Yes, this is exactly what I mean.</p><p>If you set &quot;return Input.GetMouseButton(1) ? 1 : 0;&quot;<br />-&gt; Map dragging: Right Mouse<br />-&gt; Marker OnPress event: Right Mouse</p><p>If you set &quot;return Input.GetMouseButton(0) ? 1 : 0;&quot;<br />-&gt; Map dragging: Left Mouse<br />-&gt; Marker OnPress event: Left Mouse</p><p>What I want:<br />-&gt; Map dragging: Right Mouse<br />-&gt; Marker OnPress event: Left Mouse</p><p>Those are the only events I think I can use:<br />OnClick<br />OnDoubleClick<br />OnPress<br />OnLongClick</p><p>What I would need:<br />OnClickRight</p><p>I just thought maybe I am missing something. Since your scripts are intertangled with each other heavily - plus, I can not easily raycast the markers through the raw image -, I just thought I ask before trying to change the scripts by myself.</p>]]></content>
			<author>
				<name><![CDATA[DDQ]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=1662</uri>
			</author>
			<updated>2021-07-14T11:57:47Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=7591#p7591</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Map Input only when Mouse over Map]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=7585#p7585" />
			<content type="html"><![CDATA[<p>Unfortunately I didn&#039;t understand your problem.<br />When you intercept OnGetTouchCount it automatically works for map and markers.<br />Here&#039;s a short video about it:<br /><a href="https://www.dropbox.com/s/qm5fl69sjw6qfa1/Markers%20-%20On%20Click%20Right%20Button%20.mp4?dl=0">https://www.dropbox.com/s/qm5fl69sjw6qf … 0.mp4?dl=0</a><br />Left-clicking - red circle, right-clicking - blue circle.</p>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2021-07-12T23:55:00Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=7585#p7585</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Map Input only when Mouse over Map]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=7583#p7583" />
			<content type="html"><![CDATA[<p>Thanks, this worked perfectly. Now, I can drag the map with the right mouse button to avoid faulty user input. This is because I want to have some UI functions, where you need to hold left mouse and move the cursor around to &quot;paint&quot; on the map. So, to unify user control, I also want clicking on markers to be still triggered by left mouse.</p><p>Unfortunately, when changing the button for dragging the map to right mosue, clicking on markers suddenly also only works with right click and not left click anymore. I looked into it and understand why that is (OnlineMapsControlbase / OnMapRelease). What would be the best approach to change this. I kind of understand what is going on but it&#039;s too much code to really make that decision.</p>]]></content>
			<author>
				<name><![CDATA[DDQ]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=1662</uri>
			</author>
			<updated>2021-07-12T10:25:54Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=7583#p7583</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Map Input only when Mouse over Map]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=7574#p7574" />
			<content type="html"><![CDATA[<p>Yes, you are thinking in the right direction.<br />This must be done using OnGetTouchCount and GetMouseButton(1).</p><p>GetMouseButton also is present in #else.</p>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2021-07-07T15:22:15Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=7574#p7574</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Map Input only when Mouse over Map]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=7572#p7572" />
			<content type="html"><![CDATA[<p>Thanks, sent you a mail!</p><p>Quick follow-up question:<br />I want to change drag control from Mouse 0 to Mouse 1 to keep Mouse 0 free for other tasks such as selection of elements on the map. How would I modify the code for that?</p><p>Am I right that this is only possible by modifying the code at OnlineMapsTouchForwarder in OnGetTouchCount() from GetMouseButton(0) to GetMouseButton(1)? Because this part of the code is embedded in #if UNITY_EDITOR markers. I also found GetTouchCount() in OnlineMapsControlBase. Is this the standalone counterpart?</p><p>Thanks!</p>]]></content>
			<author>
				<name><![CDATA[DDQ]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=1662</uri>
			</author>
			<updated>2021-07-07T12:31:18Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=7572#p7572</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Map Input only when Mouse over Map]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=7565#p7565" />
			<content type="html"><![CDATA[<p>Hello.</p><p>As far as I understand you are using Raw Image Touch Forwarder, right?!<br />If so, this behavior has already been fixed.<br />Email me (support@infinity-code.com) and I will send you a modified script.</p><p>If not, please explain in detail the structure of your application (I am interested in how and where the map is used).<br />Quite possibly, a small video will help a lot here.</p>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2021-07-01T17:32:48Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=7565#p7565</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Map Input only when Mouse over Map]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=7560#p7560" />
			<content type="html"><![CDATA[<p>Hi there,</p><p>is there a built-in way to limit user control over the map to when the cursor is actually over the map? I am sure I can program this myself but I thought maybe it&#039;s already there somewhere hidden.</p><p>I am using the GUI setup with &quot;Map Image&quot; where a Map Render Texture is drawn. The Map Image is positioned on the screen such as a draggable window in Windows. I can move/scroll the map even if the mouse cursor is outside of this window area.</p><p>Thanks for your help!</p>]]></content>
			<author>
				<name><![CDATA[DDQ]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=1662</uri>
			</author>
			<updated>2021-07-01T11:51:51Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=7560#p7560</id>
		</entry>
</feed>
