<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: можно ли сделать меню с перетаскиваемыми menuitem'ами?]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=10118&amp;type=atom" />
	<updated>2014-11-08T18:18:31Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=10118</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: можно ли сделать меню с перетаскиваемыми menuitem'ами?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=88129#p88129" />
			<content type="html"><![CDATA[<p>Хочу улучшить свой <a href="https://github.com/Drugoy/Autohotkey-scripts-.ahk/blob/master/Meta%20Shortcut/Meta%20Shortcut.ahk">скрипт</a>, добавив возможность сортировки итемов в меню простым драг&#039;н&#039;дропом, а по возможности и создание суб-меню при драг-н-дропе итема в итем.</p>]]></content>
			<author>
				<name><![CDATA[Drugoy]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27463</uri>
			</author>
			<updated>2014-11-08T18:18:31Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=88129#p88129</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: можно ли сделать меню с перетаскиваемыми menuitem'ами?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=88128#p88128" />
			<content type="html"><![CDATA[<p>Что вообще задумано? Меню контекстное, меню области уведомлений, главное меню, меню заголовка или собственное нестандартное уникальное меню?</p>]]></content>
			<author>
				<name><![CDATA[ypppu]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=5974</uri>
			</author>
			<updated>2014-11-08T18:02:51Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=88128#p88128</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: можно ли сделать меню с перетаскиваемыми menuitem'ами?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=88123#p88123" />
			<content type="html"><![CDATA[<p>Пример с деревом - с багом <img src="//forum.script-coding.com/img/smilies/sad.png" width="15" height="15" /><br />Баг в том, что если курсор при перетаскивании опустить далеко вниз за окно, то потом достаточно повести его совсем чуть-чуть (всё ещё не отпуская кнопку мыши), для перетаскивания вверх, хотя курсор остаётся далеко внизу под окном.<br />Делать это через позицию курсора как-то не правильно.</p><p>Ну и раз уж это дерево, то почему нельзя ветку верхнего уровня сделать под-веткой?</p><p>Пример с LV - рабочий, только кода ну уж очень много :-/</p>]]></content>
			<author>
				<name><![CDATA[Drugoy]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27463</uri>
			</author>
			<updated>2014-11-08T17:03:48Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=88123#p88123</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: можно ли сделать меню с перетаскиваемыми menuitem'ами?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=88096#p88096" />
			<content type="html"><![CDATA[<p>Кажется у нас такой темы ещё не было.<br /><a href="http://www.autohotkey.com/board/topic/10120-treeview-drag-and-drop-items/">TreeView: Drag and Drop items</a><br /></p><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header"><strong>+</strong>&nbsp;Пример с TreeView</div><div class="fancy_spoiler"><div class="codebox"><pre><code>#singleinstance force

SetTimer, TREEVIEWdragTIMER, 10
SetTimer, TREEVIEWdragTIMER, Off

Gui, Add, TreeView, gMySubroutine h195 0x200 AltSubmit 0x400
Gui, Add, Button, gMOVEdown, MOVEdown
Gui, Add, Button, gMOVEup, MOVEup

P1 := TV_Add(&quot;First parent&quot;)
P1C1 := TV_Add(&quot;Parent 1&#039;s first child&quot;, P1)  ; Specify P1 to be this item&#039;s parent.
P2 := TV_Add(&quot;Second parent&quot;)
P2C1 := TV_Add(&quot;Parent 2&#039;s first child&quot;, P2)
P2C2 := TV_Add(&quot;Parent 2&#039;s second child&quot;, P2)
P2C2C1 := TV_Add(&quot;Child 2&#039;s first child&quot;, P2C2)
P3 := TV_Add(&quot;3rd parent&quot;)
P4 := TV_Add(&quot;4th parent&quot;)
Gui, Show, ,Drag and drop experiment..  ; Show the window and its TreeView.
return

GuiEscape:
GuiClose:  ; Exit the script when the user closes the TreeView&#039;s GUI window.
ExitApp
;------------------------------------------------------------------------------
MOVEup:
TREEVIEWmoveup()
return
;------------------------------------------------------------------------------
MOVEdown:
TREEVIEWmovedown()
return
;------------------------------------------------------------------------------
MySubroutine:
If A_GuiEvent=D
{
    MouseGetPos, , OutputVarY
    SetTimer, TREEVIEWdragTIMER, On
}
return
;------------------------------------------------------------------------------
TREEVIEWdragTIMER:
OLDvalue=
;TV_Modify(A_EventInfo , &quot;Select&quot;)
GetKeyState, state, LButton, P
If state=U
{
    ;TV_Modify(A_EventInfo , &quot;Select&quot;)
    SetTimer, TREEVIEWdragTIMER, Off
    OutputVarY=
    OLDvalue=
    NEWOutputVarY=
    return
}
MouseGetPos, , NEWOutputVarY 
If NEWOutputVarY=%OutputVarY%
    return

OLDvalue:=Sub(OutputVarY, 11)
If NEWOutputVarY&lt;%OLDvalue%
{
    MouseGetPos, , OutputVarY
    TREEVIEWmoveup()
    return
}

OLDvalue:=Add(OutputVarY, 11)
If NEWOutputVarY&gt;%OLDvalue%
{
    MouseGetPos, , OutputVarY
    TREEVIEWmovedown()
    return
}
return

;////////////////////////// FUNCTIONS //////////////////////////
TREEVIEWmoveup()
{
TV_GetText(PREVitem, TV_GetPrev(TV_GetSelection()))
TV_GetText(THISitem, TV_GetSelection())
If PREVitem=
    return

; LOOPS THROUGH ITEM.. STORING THE TEXT OF CHILD ITEMS IN A STRING.. (there&#039;s gotta be a better way!!)

Loop
{
    If TV_GetChild(TV_GetSelection())=0   ; CURRENT ITEM HAS CHILD ITEMS..
        break
    TV_GetText(CHILDitem, TV_GetChild(TV_GetSelection()))
    TV_Delete(TV_GetChild(TV_GetSelection())) 
    If THISitemARRAY=
        THISitemARRAY=%CHILDitem%
    Else
        THISitemARRAY=%THISitemARRAY%|%CHILDitem%
}
Loop
{
    If TV_GetChild(TV_GetPrev(TV_GetSelection()))=0 ; CURRENT ITEM HAS CHILD ITEMS..
        break
    TV_GetText(CHILDitem, TV_GetChild(TV_GetPrev(TV_GetSelection())))
    TV_Delete(TV_GetChild(TV_GetPrev(TV_GetSelection())))
    If PREVitemARRAY=
        PREVitemARRAY=%CHILDitem%
    Else
        PREVitemARRAY=%PREVitemARRAY%|%CHILDitem%
}
If THISitemARRAY&lt;&gt;
{
    Loop, Parse, THISitemARRAY, |
        TV_Add(A_LoopField, TV_GetPrev(TV_GetSelection()))

}
If PREVitemARRAY&lt;&gt;
{
    Loop, Parse, PREVitemARRAY, |
        TV_Add(A_LoopField, TV_GetSelection())
}
TV_Modify(TV_GetSelection() , &quot;&quot;, PREVitem)
TV_Modify(TV_GetPrev(TV_GetSelection()) , &quot;Select&quot;, THISitem)
PREVitemARRAY=
THISitemARRAY=
return
}
;------------------------------------------------------------------------------
TREEVIEWmovedown()
{
TV_GetText(NEXTitem, TV_GetNext(TV_GetSelection()))
TV_GetText(THISitem, TV_GetSelection())
If NEXTitem=
    return

Loop
{
    If TV_GetChild(TV_GetSelection())=0 
        break
    TV_GetText(CHILDitem, TV_GetChild(TV_GetSelection()))
    TV_Delete(TV_GetChild(TV_GetSelection())) 
    If THISitemARRAY=
        THISitemARRAY=%CHILDitem%
    Else
        THISitemARRAY=%THISitemARRAY%|%CHILDitem%
}
Loop
{
    If TV_GetChild(TV_GetNext(TV_GetSelection()))=0 
        break
    TV_GetText(CHILDitem, TV_GetChild(TV_GetNext(TV_GetSelection())))
    TV_Delete(TV_GetChild(TV_GetNext(TV_GetSelection())))
    If NEXTitemARRAY=
        NEXTitemARRAY=%CHILDitem%
    Else
        NEXTitemARRAY=%NEXTitemARRAY%|%CHILDitem%
}
If THISitemARRAY&lt;&gt;
{
    Loop, Parse, THISitemARRAY, |
        TV_Add(A_LoopField, TV_GetNext(TV_GetSelection()))

}
If NEXTitemARRAY&lt;&gt;
{
    Loop, Parse, NEXTitemARRAY, |
        TV_Add(A_LoopField, TV_GetSelection())
}
TV_Modify(TV_GetSelection() , &quot;&quot;, NEXTitem)
TV_Modify(TV_GetNext(TV_GetSelection()) , &quot;Select&quot;, THISitem)
NEXTitemARRAY=
THISitemARRAY=
return
}
;------------------------------------------------------------------------------
Add(x, y)
{
 return x + y   ; &quot;Return&quot; expects an expression.
}
;------------------------------------------------------------------------------
Sub(x, y)
{
 return x - y   ; &quot;Return&quot; expects an expression.
}</code></pre></div></div></div><p><a href="http://www.autohotkey.com/board/topic/94364-class-lv-rows-copy-cut-paste-and-drag-listviews/">[Class] LV_Rows - Copy, Cut, Paste and Drag ListViews</a></p><p><a href="http://www.autohotkey.com/board/topic/37504-listview-drag-drop/">ListView Drag &amp; Drop</a></p>]]></content>
			<author>
				<name><![CDATA[ypppu]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=5974</uri>
			</author>
			<updated>2014-11-07T20:33:17Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=88096#p88096</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: можно ли сделать меню с перетаскиваемыми menuitem'ами?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=88061#p88061" />
			<content type="html"><![CDATA[<p>Встроенной командой Menu, похоже, что нельзя. Но может какими-нибудь dllcall&#039;ами можно на более низком уровне это сделать?<br />На крайний случай осталась идея делать gui+listview/treeview, там вроде drag&#039;n&#039;drop поддерживается нативно.</p>]]></content>
			<author>
				<name><![CDATA[Drugoy]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27463</uri>
			</author>
			<updated>2014-11-06T19:27:39Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=88061#p88061</id>
		</entry>
</feed>
