Skip to content

Rants of a Mad Programmer

Code, Code, CODE! All I see is CODE!

  • CMHC/MIS Stuff
    • How To Bring Back the Right Click Menus in BUI
    • How To Maximize the BUI Work Area
    • MainTree uScript Shared Libraries
    • UltraEdit uScript Wordfile
    • Universal Executor
  • Pictures
    • New Years 2005
    • Spokane

How To Bring Back the Right Click Menus in BUI

With the June 2004 BUI patches, we lost the function of the right click on everything except text boxes. With the code show below, you will be able to get that right click menu back without the elements that could cause problems with BUI.

menuexample

As you can see, the resulting menu has just Print, and Select All. Then on selected text, you get the following menu:

menuexample2

This allows for the use of the common clipboard functions. The modification for this can be done in 2 ways. 1, modify the topframe.js file on each BUI server; or 2, place a function in each of your uScript files that you want to have this ability.

Method 1: Modify topframe.js:

Open the topfile.js file. On windows based BUI servers, it’s located in c:\cmhcbui\cmhcweb\cmhcbui\cmhcbui\javascript . Once open, locate the following lines: (around line 26)
[sourcecode language=”javascript”]function ctxtMenu (evnt) {
evnt.returnValue = (evnt.srcElement.tagName == ‘INPUT’ || evnt.srcElement.tagName == ‘TEXTAREA’ || (evnt.ctrlKey && evnt.altKey));
}[/sourcecode]
Remove them and replace them with this set: (Download this function here)
[sourcecode language=”javascript”]// Context Menu Replacement
var oRightPopup = window.createPopup();
var oRightPopupSrcDoc
function ctxtMenu(evnt) {

oRightPopupSrcDoc = evnt.srcElement.document;

if (evnt.srcElement.tagName == ‘INPUT’ || evnt.srcElement.tagName == ‘TEXTAREA’ || (evnt.ctrlKey && evnt.altKey) || oRightPopupSrcDoc.selection.type != “None”) {
evnt.returnValue = true;
} else {
evnt.returnValue = false;

var oPopBody = oRightPopup.document.body;
var PopBodyCode;

oRightPopupSrcDoc = evnt.srcElement.document;

PopBodyCode = ”

“;
PopBodyCode = PopBodyCode + ”

“;
PopBodyCode = PopBodyCode + ”

“;
PopBodyCode = PopBodyCode + ”

“;
PopBodyCode = PopBodyCode + ”

“;
PopBodyCode = PopBodyCode + ”

“;
PopBodyCode = PopBodyCode + ”

“;
PopBodyCode = PopBodyCode + “

Print
Select All

“;

oPopBody.style.backgroundColor = “lightgrey”;
oPopBody.style.border = “solid black 1px”;
oPopBody.innerHTML = PopBodyCode;

oRightPopup.show(evnt.x+4, evnt.y+4, 120, 120, evnt.srcElement.document.body);
oRightPopup.show(evnt.x+4, evnt.y+4, 120, oPopBody.all.PopUpMenu.clientHeight+2, evnt.srcElement.document.body);
}
}
//End Replacement[/sourcecode]
Save the file and you’re done. Please note that any BUI patches you apply may remove this modification. So, keep a eye on the JavaScript files that you change.

Method 2: Use a function:

This method doesn’t require changing any of the system JavaScript files but it does require that you change any uscripts that you want to have the menu functionality.

Here’s the new function to add at the bottom of your code: (Download it as a library here.)
[sourcecode language=”plain”]function RepRightClk() is null

RightClickCode is x
%preload RightClickCode line-ending(cr)

%endpreload
$ctag(RightClickCode)

end RepRightClk[/sourcecode]
Now to use this code, add the following line after your $form() statement:
[sourcecode language=”plain”]RepRightClk()[/sourcecode]
or, if your are using the library version, use this code:
[sourcecode language=”plain”]”RepRightClk”:RepRightClk()[/sourcecode]
And that’s all there is to it.

Leave a Reply

You must be logged in to post a comment.

Friends

  • Michelle Smith

Programming

  • MSDN
  • pinvoke.net
  • VBNet

Work

  • MainTree Systems
  • Netsmart Technologies

Categories

Proudly powered by WordPress | Theme: micro, developed by DevriX.