How To Create A CheckBoxList in Maya - list

i want to create a checkbox list in Autodesk Maya (MEL only) which contains N number of items along with a check/ uncheck option next to it. so that on click of a button i can get value of all checked or unchecked items. There is a component called textscrolllist but it does not support checkbox.

Check out the "Controls" category in the MEL reference, you will find the checkBox and checkBoxGroup commands. You can query the state with the -value or -valueN flags.

Check out this site. This has helped me over the past few years when it comes to creating custom UIs in mel. Below is some block text on how to create a checkbox within a UI.
https://nccastaff.bournemouth.ac.uk/jmacey/RobTheBloke/www/mel/GUI_controls.html
// a function to be called when the checkbox gets checked.
proc on_func() {
print("checkbox on!\n");
}
// a function to be called when the checkbox gets unchecked.
proc off_func() {
print("checkbox on!\n");
}
{
// create a window
window;
// define the layout of controls added
// to the window.
columnLayout;
// create a checkbox
$c = `checkBox -label "thingy"
-onCommand "on_func"
-offCommand "off_func"`;
// show the window we last created
showWindow;
// to get the current value of the checkBox, use the -query flag
$value = `checkBox -query -value $c`;
print("check_box value = "+ $value +"\n");
}

Related

How to create WizardFormPage dynamically in Sitecore?

We are using the WizardForm xml control for implementing some sort of backend sitecore wizard. We want to add the controls to the pages (or even create new custom pages) on the fly, dynamically depending on the selection done in the previous page.
What I've already done: we called a parent control of the page control on the page (in ActivePageChanging event) and tried to add a new object of type "WizardDialogBaseXmlControl" there. But no new pages are displayed in the frontend. I still see the same number of pages in the browser's dev. tools that I added at design time in xml. I tried "SheerResponse.Redraw()", but that didn't help either.
My next attempt was to create some pages in the xml file at design time and just populate them with controls, but that doesn't work after the wizard has already loaded. Something like "ControlName.Controls.Add(new ControlName())" only works if it is called in the overridden method "OnLoad()".
This code doesn't work:
protected override bool ActivePageChanging(string page, ref string newpage)
{
if (newpage.Equals(Consts.PrototypeDetailsPageId))
{
if (IsFormItemSelected(out var formItem))
{
PrototypeDetailsPanel0.Controls.Add(new Literal("some text"));
}
else
{
SheerResponse.Alert("You must select a form item");
return false;
}
}
return base.ActivePageChanging(page, ref newpage);
}
How can I create a working wizard that adds pages and controls at runtime when they depend on changes on previous pages of the same wizard?
Sitecore WizardForm relies on the newpage parameter to process navigation between steps. So you can prepare alternative versions of wizard steps in advance and set one of them as newpage depending on values entered in the previous step. For example, this is how your code can look like:
protected override bool ActivePageChanging(string page, ref string newpage)
{
if (newpage.Equals(Consts.PrototypeDetailsPageId))
{
if (IsFormItemSelected(out var formItem))
{
newpage = "WizardPageWithAdditionalFields";
}
else
{
SheerResponse.Alert("You must select a form item");
return false;
}
}
return base.ActivePageChanging(page, ref newpage);
}
I also found it useful that wizard forms can be easily created with Interactive Dialogs from PowerShell Extensions.
Just as an alternative solution, here is an example of how you can display multiple dialogs to navigate users through a number of steps:
--Prepare step 1
$options = #{
"A"="a"
"B"="b"
}
$props = #{
Parameters = #(
#{Name="selectedOption"; Title="Choose an option"; Options=$options}
)
Title = "Step 1"
}
--Display step 1
$result = Read-Variable #props
if($result -ne "ok") { exit }
--Step 2
if($selectedOption -eq "Expected value") {
--Perform additional logic, for example modify #props to include additional steps
$props = #{
...
}
}
--Display step 2
$result = Read-Variable #props

Attachments moved away from Item after validation and before submit process in Apex

I have multiple File Browser Item fields on one page of Application in Oracle Apex.
What happens: When I miss any Item for which validation error fires, I want to hold that file to the browser but I usually loose it if I get that validation error. Is there a solution for the same like other Items fields hold previous value except File Browser Item field. Please see below ss:
Anshul,
APEX 4.2 is very old and no longer supported. A later (or preferably latest) version of APEX will behave differently as Dan explained above.
Can you import your application into apex.oracle.com (which is running APEX 20.1) and you will probably see better results. Based on this you can hopefully use it as justification to upgrade your environment.
Regards,
David
Go to your page-level attributes and a function like the following in the Function and Global Variable Declaration:
function validateItems(request) {
var $file1 = $('#P68_FILE_1');
var $file2 = $('#P68_FILE_2');
var errorsFound = false;
if ($file1.val() === '') {
errorsFound = true;
// Show item in error state
}
if ($file2.val() === '') {
errorsFound = true;
// Show item in error state
}
if (!errorsFound) {
// I think doSubmit was the name of the function back then. If not, try apex.submit
doSubmit(request);
} else {
// Show error message at top of page, I'll use a generic alert for now
alert('You must select a file for each file selector.');
}
}
Then, right-click the Create button and select Create a Dynamic Action. Set the name of the Dynamic Action to Create button clicked.
For the Action, set Type to Execute JavaScript Code. Enter the following JS in code:
validateItems('CREATE');
Finally, ensure that Fire on Initialization is disabled.
Repeat the process for the Save button, but change the request value passed to validateItems to SAVE.

Unchecking checkbox in oracle apex

Created an report with checkbox using apex_item and when checked more than one check box i will display alert message "not to check more than one checkbox with ok button " after clicking ok it should be unchecked . please find my JavaScript code that displays alert message
if($("input[type=checkbox]:checked").length > 1)
{
var msg = alert('You are not allowed to select more than one employee');
}
It's best to use the APEX JavaScript APIs for this type of thing. You can find them here: https://apex.oracle.com/jsapi
If you're getting started with JavaScript and APEX, you may find these slides useful: https://www.slideshare.net/DanielMcGhan/getting-started-with-javascript-for-apex-developers
Here's a solution that should work for you (just change the name of the item to match yours):
var cbItem = apex.item('P1_CHECKBOX');
if (cbItem.getValue().length > 1) {
alert('You are not allowed to select more than one employee');
cbItem.setValue(); // Passing nothing to clear the value
}

Behavioral discrepancy in Tkinter listbox, arrow keys vs. mouse click

My environment is Python 2.7, running on Windows 7.
I'm trying get a Tkinter Listbox to trigger a callback in response to the user changing the 'active' item (i.e. the item with focus). I'm using a binding to the <<ListboxSelect>> event to make this happen, and it's working -- sort of.
The callback itself is supposed to check what the new active item is, and carry out some processing accordingly. This logic operates the way I expect when I change the active item via the up/down arrow keys. But when I point & click on a new item instead, the code mistakenly identifies the prior active item as the current one.
Here's a stripped-down code sample that illustrates the behavior I'm getting:
import Tkinter as tk
#Root window
root = tk.Tk()
#Callback to show focus change
def updateDisplay(*args):
focusIndex = str(lb.index(tk.ACTIVE))
ctrlFI.set('Focus is at index '+focusIndex)
#Control variables
ctrlLB = tk.StringVar()
ctrlFI = tk.StringVar()
#Widgets
lb = tk.Listbox(root,
width=20, height=10,
relief=tk.FLAT,highlightthickness=0,
selectmode=tk.EXTENDED,
activestyle='dotbox',
listvariable=ctrlLB)
lbl = tk.Label(root,
justify=tk.LEFT, anchor=tk.W,
textvariable=ctrlFI)
lb.grid(row=0,column=0,sticky=tk.NW,padx=(5,0),pady=5)
lbl.grid(row=1,column=0,columnspan=2,sticky=tk.NW,padx=5,pady=5)
#Listbox binding to trigger callback
lb.bind('<<ListboxSelect>>',updateDisplay)
#Initializations to prep GUI
ctrlLB.set('Index0-entry Index1-entry Index2-entry Index3-entry Index4-entry')
ctrlFI.set('Ready')
#Begin app
tk.mainloop()
Here are the results when you use the arrow keys:
But here's what you get when you click with the mouse:
The information 'lags' one behind, showing the prior selection instead. (If you click the same item a second time, it 'catches up.')
So my questions are:
What is causing the discrepancy?
How do I fix it so the mouse click gives the right result?
The active item is not necessarily the same as the selected item. When you press the mouse down it changes the selected value but it does not change the active item. The active item only changes once you release the mouse button.
You should be able to see this by clicking and holding the mouse button over an item that is not currently selected. When you do, you'll see something like this:
In the above image, the active item is the one surrounded by a dotted outline. The selected item is in blue. When your code displays the 'focus', it's displaying the active element rather than the selected element.
If you want the selected item, you need to use curselection to get the index of the selected item. It returns a tuple, so in extended mode you need to get the first element that is returned (eg: lb.curselection()[0]). Be sure to handle the case where curselection returns an empty string.

Show appbar button if item is selected

I am writing an app with an appbar and item list. I want to add some buttons to the appbar which should appear only when the list item is selected.
So, how to show an additional button on an appbar when the item of the list is selected?
This is Windows 8 Metro style C#/XAML application.
<AppBar x:Name="bottomAppBar" IsOpen="True" IsSticky="True">
...
private void itemGridView_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (itemGridView.SelectedItems.Count > 0)
{
nextButton.Visibility = Windows.UI.Xaml.Visibility.Visible;
}
else
{
nextButton.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
}
}
Create the additional app bar button and set its Visibility property to Collapsed.
In the SelectionChanged event handler of the list, set the buttons Visibility property to either Visible or Collapsed depending on whether the list item is being selected or deselected.
Set AppBar.IsOpen property instead of Visibility.