Scrollbar context menu in (BROWSE, MULTILINE, PICKLIST etc)

This forum is for eXpress++ general support.
Post Reply
Message
Author
User avatar
unixkd
Posts: 579
Joined: Thu Feb 11, 2010 1:39 pm

Scrollbar context menu in (BROWSE, MULTILINE, PICKLIST etc)

#1 Post by unixkd »

Hi all

How can one add to the Scrollbar popup/context menu in (BROWSE, MULTILINE, PICKLIST etc)

Joe

User avatar
Tom
Posts: 1234
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: Scrollbar context menu in (BROWSE, MULTILINE, PICKLIST e

#2 Post by Tom »

A DCBROWSE (a XbpBrowse) has a "oVScroll" object for the vertical and a "oHscroll" object for the vertical scrollbar. Unfortunately, those are protected, so you can't access them like this:

Code: Select all

* won't work:
@ 0,0 DCBROWSE oBrowse ... EVAL {|o|oHScroll:LbClick := {||MsgBox('Right click in horizontal scrollbar')}}
You need to traverse the childlist of your browse object and look for scrollbars (IF oBrowse:ChildList():IsDerivedFrom('XbpScrollbar') .and. oBrowse:ChildList():type == XBPSCROLL_HORIZONTAL -> this is the horizontal scrollbar of the browse), maybe in the EVAL clause of DCREAD (DCREAD ... EVAL {||FindScrollBars(oBrowse)}). After that, you can place any code you want in the RbClick (or any other) slot. It's easier to do something like this in a custom handler You may create a menu using the DCMENU commands and do something like this:

Code: Select all

DCSUBMENU oContextMenu // create as a PRIVATE, so the handler can access it, otherwise create a HANDLERBLOCK
DCMENUITEM 'Test' PARENT oContextMenu ACTION {||MsgBox('Popup menu for horizontal scrollbar')}

Code: Select all

DCREAD ... HANDLER MyContextHandler REFERENCE oBrowse
...
STATIC FUNCTION MyContextHandler(nEvent,mp1,mp2,oXbp,oDialog,GetList,oBrowse)
LOCAL i
IF nEvent == xbeM_RbDown .AND: oXbp:IsDerivedFrom('XbpScrollBar') .and. oXbp:type == XBPSCROLL_HORIZONTAL .and. oXbp:SetParent()==oBrowse // must be the horiz. scrollb. of the browse
  oContextMenu:Popup(Xbp,mp1)
ENDIF
...
RETURN DCGUI_NONE
This is untested code, written here directly. There maybe errors/typos in it.
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

User avatar
unixkd
Posts: 579
Joined: Thu Feb 11, 2010 1:39 pm

Re: Scrollbar context menu in (BROWSE, MULTILINE, PICKLIST e

#3 Post by unixkd »

Hi Tom

Your suggestion worked as expected. It appear the default context menu is overloaded by my custom menu. With this, I will just implement the default menu items namely:

Scroll Here
Top
Bottom
Page Up
Page Down
Scroll Up
Scroll Down

and then add my own menu items.

Thanks

User avatar
Tom
Posts: 1234
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: Scrollbar context menu in (BROWSE, MULTILINE, PICKLIST e

#4 Post by Tom »

Thanks
A pleasure. :)

If you use a handlerblock instead of the HANDLER clause, you can make the menu LOCAL and hand it to the handler function in the codeblock.
It appear the default context menu is overloaded by my custom menu.
Ooops. I wasn't aware that there is a contect menu in a scrollbar. :oops: Just tried it out - and it doesn't seem to work well (top/bottom has no effect). So, maybe I take your suggestion and replace those with a custom menu aswell.

A better choice would be additional buttons like this (see picture). Hard to implement, since XbpScrollbars are system controls and change their appearance by system settings.
Attachments
scrollbuttons.jpg
scrollbuttons.jpg (4.08 KiB) Viewed 11991 times
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

User avatar
Tom
Posts: 1234
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: Scrollbar context menu in (BROWSE, MULTILINE, PICKLIST e

#5 Post by Tom »

Addition: You can write one single handler function used in any DCREAD.
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

User avatar
rdonnay
Site Admin
Posts: 4813
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Scrollbar context menu in (BROWSE, MULTILINE, PICKLIST e

#6 Post by rdonnay »

Ooops. I wasn't aware that there is a contect menu in a scrollbar
What context menu? I don't get one.
The eXpress train is coming - and it has more cars.

User avatar
Tom
Posts: 1234
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: Scrollbar context menu in (BROWSE, MULTILINE, PICKLIST e

#7 Post by Tom »

Right click with a mouse in a scrollbar connected to a browse:
Attachments
rightclickbrowse.jpg
rightclickbrowse.jpg (14.29 KiB) Viewed 11974 times
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

User avatar
rdonnay
Site Admin
Posts: 4813
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Scrollbar context menu in (BROWSE, MULTILINE, PICKLIST e

#8 Post by rdonnay »

I tried that. I get nothing.
Maybe it needs to be enabled in some way.
The eXpress train is coming - and it has more cars.

skiman
Posts: 1199
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Scrollbar context menu in (BROWSE, MULTILINE, PICKLIST e

#9 Post by skiman »

Hi,

I also have that context menu. Never seen it before, but it is there.

Looks as Puge UP/Down are working, go Top or Bottom are not working.

I don't think that any of my isers ever tried this. It is not important for my application.
Best regards,

Chris.
www.aboservice.be

User avatar
unixkd
Posts: 579
Joined: Thu Feb 11, 2010 1:39 pm

Re: Scrollbar context menu in (BROWSE, MULTILINE, PICKLIST e

#10 Post by unixkd »

Hi all

I am aware that some of those menu items are not working but that is not my problem. I am not a low level guy but it appear that even in other programming languages, they are not working too. May be it is a Windows OS bug. Now with what Tom shown me, I may be able to achieve my objectives. In our application, each user has a profile. When a user log in on a work station, the application will load according to his/her saved profile. One of the things we are contemplating is ability of individual user to change the presentation parameter of browse for example at runtime and save it to his profile so that which ever workstation he logs on to, the presentation will be displaced there and so on...

Joe

Post Reply