Page 1 of 1

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

Posted: Mon Mar 23, 2015 2:32 am
by unixkd
Hi all

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

Joe

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

Posted: Mon Mar 23, 2015 3:00 am
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.

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

Posted: Mon Mar 23, 2015 3:56 am
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

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

Posted: Mon Mar 23, 2015 4:39 am
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.

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

Posted: Mon Mar 23, 2015 5:46 am
by Tom
Addition: You can write one single handler function used in any DCREAD.

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

Posted: Mon Mar 23, 2015 6:20 am
by rdonnay
Ooops. I wasn't aware that there is a contect menu in a scrollbar
What context menu? I don't get one.

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

Posted: Mon Mar 23, 2015 7:13 am
by Tom
Right click with a mouse in a scrollbar connected to a browse:

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

Posted: Mon Mar 23, 2015 7:43 am
by rdonnay
I tried that. I get nothing.
Maybe it needs to be enabled in some way.

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

Posted: Mon Mar 23, 2015 9:10 am
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.

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

Posted: Mon Mar 23, 2015 10:41 am
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