Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

LVX: Row highlighting and cell editing for ListView controls


  • This topic is locked This topic is locked
55 replies to this topic
polyethene
  • Members
  • 5519 posts
  • Last active: May 17 2015 06:39 AM
  • Joined: 26 Oct 2012
This wraps Micas code for cell editing and evls code for row colouring in an easy to use set of functions.

Example (sorry for lack of imagination -_-'):
Gui, Add, ListView, w250 r8 vLV_Sample gEditLV Grid, Day|Activity
LV_Add("", "Monday") 
LV_Add("", "Tuesday") 
LV_Add("", "Wednesday", "pre-set value") 
LV_Add("", "Thursday") 
LV_Add("", "Friday") 
LV_Add("", "Saturday") 
LV_Add("", "Sunday") 
Loop, 3
	LV_ModifyCol(A_Index, "AutoHdr")

LVX_Setup("LV_Sample")
LVX_SetColour(3, 0xce0000, 0xffffff)

LVX_SetColour(2, 0x008000)
LVX_SetColour(5, 0xff8000, 0xffff00)
LVX_SetColour(6, 0xffffff, 0x0000bb)
LVX_SetColour(7, 0xffffff, 0x0000ff)

Gui, Show, , Test
Return

EditLV:
If A_GuiEvent = DoubleClick
	LVX_CellEdit()
Return

GuiClose:
ExitApp

Produces:
Posted Image

Download with instructions

autohotkey.com/net Site Manager

 

Contact me by email (polyethene at autohotkey.net) or message tidbit


ahklerner
  • Members
  • 1386 posts
  • Last active: Oct 08 2014 10:29 AM
  • Joined: 26 Jun 2006
Very cool....

It is hard to read what is being typed on my pc though:
Posted Image
Posted Image
ʞɔпɟ əɥʇ ʇɐɥʍ

polyethene
  • Members
  • 5519 posts
  • Last active: May 17 2015 06:39 AM
  • Joined: 26 Oct 2012
Have you customized your font settings? The edit control is set to match the same dimensions of the cell so you could try increasing font size in your script.

autohotkey.com/net Site Manager

 

Contact me by email (polyethene at autohotkey.net) or message tidbit


ahklerner
  • Members
  • 1386 posts
  • Last active: Oct 08 2014 10:29 AM
  • Joined: 26 Jun 2006
no font setting changes that i know of. IBM Thinkpad laptop. I made the following changes to my copy of your script:
...
If i
	{
		Gui, %A_Gui%:Add, Edit, Hwndh ve Hide r1
		h += i := 0
	}
...
...
	GuiControl, , e, %t%
	GuiControl, Move, e, x%bx% y%by% w%bw% ; h%bh%
	GuiControl, Show, e
...


ahklerner
  • Members
  • 1386 posts
  • Last active: Oct 08 2014 10:29 AM
  • Joined: 26 Jun 2006
Font changes mess it up, though.

[color=red]Gui, Font, s12[/color]
Gui, Add, ListView, w250 r8 vLV_Sample gEditLV Grid, Day|Activity
LV_Add("", "Monday") 
LV_Add("", "Tuesday") 
LV_Add("", "Wednesday", "pre-set value") 
LV_Add("", "Thursday") 
LV_Add("", "Friday") 
LV_Add("", "Saturday") 
LV_Add("", "Sunday") 
Loop, 3
   LV_ModifyCol(A_Index, "AutoHdr")
[color=red]Gui, Font, s20[/color]
Gui, add, Text, , Blah
LVX_Setup("LV_Sample")
...


majkinetor
  • Moderators
  • 4512 posts
  • Last active: Jul 29 2016 12:40 AM
  • Joined: 24 May 2006
If i remember correctly about the original code, it may be hard to get it working with RETURN instead clicking.

also, edit appers on wrong place here - 2 rows bellow.
Posted Image

polyethene
  • Members
  • 5519 posts
  • Last active: May 17 2015 06:39 AM
  • Joined: 26 Oct 2012

If i remember correctly about the original code, it may be hard to get it working with RETURN instead clicking.

You just need a way to break the loop from a different thread when using a hotkey or have the loop check with GetKeyState() and iterate at high frequency. I'll decide on something for next vers.

Font changes mess it up

also, edit appers on wrong place here - 2 rows bellow.

Calculating these offsets can be difficult as there are numerous factors that affect the spacing. I'll try fix this too for next time.

autohotkey.com/net Site Manager

 

Contact me by email (polyethene at autohotkey.net) or message tidbit


ahklerner
  • Members
  • 1386 posts
  • Last active: Oct 08 2014 10:29 AM
  • Joined: 26 Jun 2006
thx :)
Posted Image
ʞɔпɟ əɥʇ ʇɐɥʍ

  • Guests
  • Last active:
  • Joined: --
Titan!: s/colour/color/

polyethene
  • Members
  • 5519 posts
  • Last active: May 17 2015 06:39 AM
  • Joined: 26 Oct 2012
I'll add the archaic spelling as an overload lol..

autohotkey.com/net Site Manager

 

Contact me by email (polyethene at autohotkey.net) or message tidbit


majkinetor
  • Moderators
  • 4512 posts
  • Last active: Jul 29 2016 12:40 AM
  • Joined: 24 May 2006

You just need a way to break the loop from a different thread when using a hotkey or have the loop check with GetKeyState() and iterate at high frequency.

I beleive subclasing is the only real solution. AHK doesn't send return key as event. I recently posted Subclass function and using it u can make it work with Return in few lines of code.


Calculating these offsets can be difficult as there are numerous factors that affect the spacing.

Acctually, you can get rectangle of selected item using API, and you can get column width using AHK.
Posted Image

polyethene
  • Members
  • 5519 posts
  • Last active: May 17 2015 06:39 AM
  • Joined: 26 Oct 2012

Acctually, you can get rectangle of selected item using API, and you can get column width using AHK.

I get both with API, just for consistency. You said the edit control is positioned wrongly on your comp, could you please give a screenshot?

Uploaded 1.03b which introduces hotkeys. When cell editing press Esc to cancel current input or Enter to save it. You can change these hotkeys with the new function of course. I will try to improve on this so edit mode can be invoked via keyboard navigation on the cells (like Excel). Another improvement I want to add is bounding colouring information to rows, so you can enable sorting on the ListView and still retain highlighting for the corresponding cells.

autohotkey.com/net Site Manager

 

Contact me by email (polyethene at autohotkey.net) or message tidbit


majkinetor
  • Moderators
  • 4512 posts
  • Last active: Jul 29 2016 12:40 AM
  • Joined: 24 May 2006
On 2 totaly different computers:
Posted Image

About ENTER it was not the problem to make it work when edit is active, but to enter edit state with it.
Posted Image

garry
  • Spam Officer
  • 3219 posts
  • Last active: Feb 06 2016 09:32 PM
  • Joined: 19 Apr 2005
thank you Titan
here a complet example with 1.03b , change functions when Titan changed
example with add and delete button
<!-- m -->https://ahknet.autoh...LVX_EX_103b.ahk<!-- m -->

Posted Image

polyethene
  • Members
  • 5519 posts
  • Last active: May 17 2015 06:39 AM
  • Joined: 26 Oct 2012
Nice work garry :)

majkinetor could you please try 1.045b and tell me whether the y-alignment has been corrected or not?

autohotkey.com/net Site Manager

 

Contact me by email (polyethene at autohotkey.net) or message tidbit