Source language: Translate to:

Changing part of text color in a Listbox

General questions about NeoBook

Moderator: Neosoft Support

Changing part of text color in a Listbox

Postby fkapnist » Tue Dec 09, 2014 7:10 am

Neosoft Support wrote:You can check the resource center http://www.neosoftware.com/neobook, but I don't think there is a way to make a multi-colored list box.


I found a quick and dirty solution for changing part of the text color in a Listbox. Not too elegant as far as programming goes. But for the end user it is rather impressive... The top image shows the basic idea. An Article with the desired font color is pasted over the Listbox. The Article reads from a text file that is dynamically updated by a subroutine every time the Listbox changes. Align them together and remove the Article's scrollbar. They will then update at the same time, side by side.

Image

The scrollbars and black text belong to the Listbox. The blue text belongs to the Article overlay. Mouseover the scrollbar and the Article is hidden so the user can click on Listbox items. Mouseout of the scroll area and the blue text Article is visible again. The Article text file subroutine only handles the top six updated items and is easy to script, whereas the Listbox might contain hundreds of items. This example changes a column color but you can also make an Article overlay for a specific row...

The only glitch is that if the user actually does scroll through the Listbox I need a way to scroll back (Sendkey, etc.) the Listbox to "Home" with a Mouseout so the ListBox will again align with the top six items of the blue text Article. I can get the result I want by setting the contents of the Listbox [ListBoxGetItem] to a variable. Then I delete "All" with [ListBoxDeleteItem]. This automatically forces the scrollbar to the top and left position no matter where it is. Then I reload "All" the contents variable with [ListBoxAddItem], which aligns the first six items in the Listbox with the blue text Article overlay.

Does anyone know a better method?

:!: :?:
.
Last edited by fkapnist on Tue Dec 09, 2014 12:45 pm, edited 5 times in total.
User avatar
fkapnist
 
Posts: 348
Joined: Mon Nov 17, 2014 4:24 pm
Location: Greece

Re: Changing part of text color in a Listbox

Postby fkapnist » Tue Dec 09, 2014 7:18 am

With this general method you can probably add tiny icons to a Listbox....

:lol:
User avatar
fkapnist
 
Posts: 348
Joined: Mon Nov 17, 2014 4:24 pm
Location: Greece

Re: Changing part of text color in a Listbox

Postby Neosoft Support » Tue Dec 09, 2014 11:38 am

Interesting solution.

The only glitch is that if the user actually does scroll through the Listbox I need a way to scroll back (Sendkey, etc.) the Listbox to "Home" with a Mouseout so the ListBox will again align with the top six items of the blue text Article.


Here's a trick you can use to jump to the top of the list box:

ListBoxGetItem "ListBox1" "1" "[ListBox1]"

The third parameter is the variable assigned to the list box.
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5603
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Re: Changing part of text color in a Listbox

Postby fkapnist » Tue Dec 09, 2014 12:28 pm

Neosoft Support wrote:Interesting solution.

The only glitch is that if the user actually does scroll through the Listbox I need a way to scroll back (Sendkey, etc.) the Listbox to "Home" with a Mouseout so the ListBox will again align with the top six items of the blue text Article.


Here's a trick you can use to jump to the top of the list box:

ListBoxGetItem "ListBox1" "1" "[ListBox1]"

The third parameter is the variable assigned to the list box.


Thanks! Before I saw your jump to top solution, I also discovered this:

I do not need to control the scroll action of the Listbox after all. I can get the result I want by setting the contents of the Listbox [ListBoxGetItem] to a variable. Then I delete "All" with [ListBoxDeleteItem]. This automatically forces the scrollbar to the top and left position no matter where it is. Then I reload "All" the contents variable with [ListBoxAddItem], which aligns the first six items in the Listbox with the blue text Article overlay.

For my next experiment I will try to put tiny icons in the Article column.


:idea:
Last edited by fkapnist on Tue Dec 09, 2014 12:43 pm, edited 2 times in total.
User avatar
fkapnist
 
Posts: 348
Joined: Mon Nov 17, 2014 4:24 pm
Location: Greece

Re: Changing part of text color in a Listbox

Postby fkapnist » Tue Dec 09, 2014 12:37 pm

fkapnist wrote:
Neosoft Support wrote:Interesting solution.

The only glitch is that if the user actually does scroll through the Listbox I need a way to scroll back (Sendkey, etc.) the Listbox to "Home" with a Mouseout so the ListBox will again align with the top six items of the blue text Article.


Here's a trick you can use to jump to the top of the list box:

ListBoxGetItem "ListBox1" "1" "[ListBox1]"

The third parameter is the variable assigned to the list box.


Thanks! Before I saw your jump to top solution, I also discovered this:

I do not need to control the scroll action of the Listbox after all. I can get the result I want by setting the contents of the Listbox [ListBoxGetItem] to a variable. Then I delete "All" with [ListBoxDeleteItem]. This automatically forces the scrollbar to the top and left position no matter where it is. Then I reload "All" the contents variable with [ListBoxAddItem], which aligns the first six items in the Listbox with the blue text Article overlay.

For my next experiment I will try to put tiny icons in the Article column.


:idea:



I just tried ListBoxGetItem "ListBox1" "1" "[ListBox1]" and found it only works in my PUB if something in the Listbox is first clicked on (focus required). My solution works with Mouseout no matter what....


:|
Last edited by fkapnist on Tue Dec 09, 2014 12:43 pm, edited 1 time in total.
User avatar
fkapnist
 
Posts: 348
Joined: Mon Nov 17, 2014 4:24 pm
Location: Greece

Re: Changing part of text color in a Listbox

Postby fkapnist » Tue Dec 09, 2014 11:07 pm

Using this basic method I was able to put icons into the Listbox that update dynamically (according to the URL type) when the Listbox changes.
It works very well. Check it out here: http://www.neosoftware.com/community/viewtopic.php?f=1&t=20821


:idea:
.
User avatar
fkapnist
 
Posts: 348
Joined: Mon Nov 17, 2014 4:24 pm
Location: Greece


Return to General NeoBook Discussions

Who is online

Users browsing this forum: Dudus and 3 guests