1. Tomáš Podzimek
  2. PowerBuilder
  3. Tuesday, 11 October 2022 12:42 PM UTC

Hello,

a ribbon related question: how to get a current item of a LargeButton menu?

Consider a LargeButton with a menu:

<LargeButton Text="Button" PictureName="" DefaultCommand="false" Tag="button" PowerTipText="" PowerTipDescription="" Visible="true">
	<Menu>
	  <Item Text="item 1" PictureName="" Clicked="ue_click" Tag="item1" Shortcut=""/>
	  <Item Text="item 2" PictureName="" Clicked="ue_click" Tag="item2" Shortcut=""/>
	</Menu>
</LargeButton>

Let's set current item of a menu as item2:

RibbonLargeButtonItem lr_LargeButton
RibbonMenuItem lmi_item
RibbonMenu lm_menu 

int li_i

if this.getitembytag('button', ref lr_LargeButton) = 1 then
	
	if lr_LargeButton.getmenu(ref lm_menu) <> 1 then return	-1
	

	for li_i = 1 to lm_menu.getitemcount()
		lm_menu.getitem(li_i, lmi_item)
		
		if lmi_item.tag = 'item2' then			
			// set menu item
			lmi_item.visible = ab_visible
			this.setitem(lmi_item)
			
			// set menu 
			lm_menu.setitem(li_i, lmi_item)				
			this.setitem(lm_menu)
			
			// set button
			lr_LargeButton.setmenu(lm_menu)				
			this.setitem(lr_LargeButton)				

			exit
		end if			
	next
end if

And now...how to tell if the current item of LargeButton is item1 or item2? I am able to obtain a button menu, but I don't know how to find out which item is selected. Maybe I am missing something elementary?

Regards,

Tomáš

 

Peter Pang @Appeon Accepted Answer Pending Moderation
  1. Wednesday, 12 October 2022 08:04 AM UTC
  2. PowerBuilder
  3. # 1

Hi Tomáš,

 

RibbonMenuItem has a Checked property, which you can use to mark the item as last clicked.

Please refer to the RibbonMenuItem.Checked practice in the Example Graph App that comes with PB:

Window: w_mdi

Function: wf_add_ribbonbar_window

  

Best Regards,

Peter

Attachments (1)
Comment
  1. Tomáš Podzimek
  2. Thursday, 13 October 2022 19:20 PM UTC
Hi Peter,

thanks. It looks promising, I will try it.

Regards,

Tomáš
  1. Helpful
There are no comments made yet.
Tomáš Podzimek Accepted Answer Pending Moderation
  1. Tuesday, 11 October 2022 13:17 PM UTC
  2. PowerBuilder
  3. # 2

Hi René,

let's say I want to know what item was used/clicked last, so I can save it and the next time the form opens, set the right item as visible.

I know how to handle a click of an item. I just need to know what item was clicked last. It thought there must be a clever way than an instance user variable.

Tomáš

Comment
  1. René Ullrich
  2. Tuesday, 11 October 2022 13:22 PM UTC
You must store the last clicked item somewhere. You can use instance variable, registry or whatever (depends on how long you will store it). But there is no automatism. You have to implement it yourself.
  1. Helpful 1
  1. Tomáš Podzimek
  2. Tuesday, 11 October 2022 13:28 PM UTC
OK, thanks.
  1. Helpful
There are no comments made yet.
René Ullrich Accepted Answer Pending Moderation
  1. Tuesday, 11 October 2022 13:06 PM UTC
  2. PowerBuilder
  3. # 3

Hi Tomáš,

What do you mean with "selected item"? AFAIK you can't "select" one so you can't check which item is selected.

If the user clicks on a item the event you defined for the item is triggered (in your case the ue_click event). In this event you have the itemhandle as parameter to get more information about the clicked item.

HTH,

René

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.