I use the create command in livecode to dynamically create several objects (graphic, field, button) depending of some conditions. I use "lock screen" and set up all properties: width, height, textSize and many many more... Then "unlock screen".
Here is the problem:
The syntax create btn "Rider1" creates a standard button, but I need an ption menu button. In the project browser, there is also an option menu "Button: Rider2Number", but trying to modify the button that was created by script fails: there is no option menu or popup menu in the list of button types. There are opaque and standard and some variations. It seems like the standard button and the option menu are two different objects. Which prefix (like btn) I should use to create an option menu by script?
You have to first the the style of the button, then set its menuMode:
set the style of last button to "menu"
set the menuMode of last button to "comboBox"
There are two ways to fully set the required properties:
1- If you already have an option button (call it "XYZ"), you can:
create button
set the properties of last button to the properties of btn "XYZ"
You then will need to modify things, like its name and contents.
2- You can set the properties of the "templateButton" as required, perhaps, again, to the properties of btn "XYZ". Then all new buttons will start off that way. You will still have to modify a bit as in the above case.
This is all so that you need not set the many properties that distinguish one type from another; that is tedious. Look up the "templateButton" in the dictionary. This property can be set on the fly, to any number of different types of buttons. Do you see? If you had a suite of button styles, you set the properties of the templateButton to any of those on the fly, and then any newly created button will be of that type.
There is only one button object class. The difference between the many types you are interested in is the "menuMode". Check this out in the dictionary.
Related
Hello we are using a script in KTM to make the button on the validation form invisible. The project has several classes and depending on the class we hide the buttons.
ValidationForm.Buttons.ItemByName ("btnDBFuzzy_2"). Visible = False
Now we have to use tabs in the project. I'm looking silly, but can't find the way to control the buttons on the tabs.
Maybe someone here has an idea?
Since your button is now on a different tab, you would need to make use of the following syntax: ValidationForm.Tabs.ItemByName("Tab A"). The same applies to all other controls.
We would like to change the font, color and size of the text displayed in message boxes.
Can/how do you VBA this?
Nothing tried, we are not finding any help in online manuals, including the Microsoft help site.
We would like to make the message box big, bold and loud.
Easy answer: You can't.
That's why you can't find anything about it in the official documentation of the MsgBox function.
A workaround can be to create your own UserForm where you are free in how to style it.
Add a UserForm in your workbook's code module, and configure it with as many Label and CommandButton controls as needed.
If the label text will be static, you can configure these all through the Properties window in the IDE:
Labels, Command Buttons, etc., are accessible Controls on the UserForm, and can be altered dynamically during runtime if needed, e.g., during the form's Initialize or Activate or any other event handlers. Controls on the form can even alter other controls, for example you could leverage the command button's Click event handler to modify the text associated with Label1 control, etc.
You can even add (or remove) controls (labels and such) dynamically, too, and fully control their appearance/formatting/etc.
I have been looking for a way to create a menu item, and some sub-menus relative to that menu.
I want this to be the menu the users see when they log in, instead of the "Messaging" Menu.
Basically:
I want a menu on the top of the page, and it has to be the first one.
This menu needs to be the menu users see when they login.
On the left bar of OpenERP, i just want to add a few external links.
On the body of the page, i just want to write some welcoming text.
How do i do this? Do i need to create a new module? Or is it much simpler?
Thanks!
You must create a new module see here.
And on this module, you must create an XML file to define new menu entries like this :
and if you need a sub-menu (under My Menu):
More explanations on here
We have a legacy code MFC VC++ one.
I need to add a message box asking for 2 inputs(both are string).
No need to consider security issue. Just need input.
How to do this?
I am really not MFC guy. Searched several pages. Not good for me.
Best
Thank you
To get input you want a dialog, not a message box.
Assuming you're working in VS, you'll go to the resource view, expand the tree, right-click on "Dialog" and pick "Insert Dialog" from the pop-up menu. That'll let you draw your dialog, where you'll insert a couple of edit controls, probably with a static control next to each to describe what to enter there, etc. It'll start out with Ok and Cancel buttons, so you don't need to add those.
Once you've drawn what the dialog will look like, you need to add some code and such to back it up. Right click on one of the controls, and pick "Add Class" from the menu. That'll bring up a dialog that'll ask for the name of the class for the dialog. You'll enter some class name (e.g., "my_input") and it'll pick matching names for the source/header file. You'll probably want to change the base class from "CDHtmlDialog" to "CDialog". When you're happy with that, click "finish" and it'll create the class/files.
Then you'll go back to the dialog, right-click in one of the edit controls, and choose "add variable". To keep things simple toward the far right, change the "Category" from "Control" to "Value". Then pick a name for the string you'll receive from that control and click Ok. Repeat for the other control. Repeat for the other edit control (obviously choosing a different name for its variable).
The last thing you need to add is some code to invoke that dialog. To do that, you'll need to include the dialog's header in where you're going to use it. Then you'll add a bit of code something like:
my_input inp;
if (inp.DoModal() == IDOK) {
// retrieve your two strings
CString input1 = inp.field1;
Cstring input2 = inp.field2;
}
Language: Progress 10.1C
I have a Windows form, and on it I dynamically create a number of widgets (toggle-boxes in this case). I can create anything from 0 to 64 widgets, depending on how many do-hickies the user has in the current collection. As the user changes from one collection to another, the widgets are deleted or created as needed. The form will resize according to how many widgets are displayed.
The user can check any number of them and perform certain processes on the checked items by selecting actions from a menu bar, toolbar or keyboard shortcuts. But I also want the user to be able to right-click on a single widget, which should bring up a popup menu with actions that can be performed on just the one clicked item, whether it's checked or not.
In itself, this is pretty straight forward. In the past I had done this kind of thing (in other languages) by having a single popup menu that pops up when the user clicks on any one of the dynamic controls. But I'm having a hard time doing this simple thing in Progress:
I am unable to have one popup menu that responds to the right-click of all the widgets. I tried creating a single popup menu, and then as I create each dynamic widget, I set its popup-menu attribute to this menu. The problem is that a menu can only be applied to one widget. Once I've assigned it to Widget1, I cannot assign it to Widget2. This leads one to think of creating a seperate but identical menu for each widget. And as the widgets are destroyed and recreated, so will these menus. In a single session I will create and destroy hundreds or even thousands of these identical menus, while the user might use one of them once or twice. Or not at all. So this does not seem like a good option to me.
My next solution would be to create a single menu which I can pop up programatically, but all attempts to programatically pop up a menu have failed. I have tried APPLY "MENU-DROP" TO MENU MyMenu and other similar things and I cannot for the life of me figure out how to do it. I also find it very difficult to search for information on this. It's as if nobody else has ever tried this, and the rare cases where someone has asked about it, there has been no satisfactory answers. I'm suspecting this cannot be done.
While trying all these things, I have also had endless problems with the events MOUSE-MENU-DOWN, MOUSE-MENU-UP and MOUSE-MENU-CLICK. MOUSE-MENU-CLICK seems to never happen, not for my dynamic widgets anyway. I am unable to figure out why. MOUSE-MENU-UP occurs sometimes, but it depends on what happens in MOUSE-MENU-DOWN and other events of the widgets as well as the widgets' parents. I have not been able to figure out exactly when it will or won't fire, it's very counter-intuitive. MOUSE-MENU-DOWN is the only one I can count on firing.
So: I can't show a menu programatically, I can only show it by right clicking on the menu's parent. The only way to avoid having hundreds of identical menus, is to have a popup menu on the parent of the widgets, for example the default frame.
With a static popup menu on the default frame, I can right-click on the widgets and the menu will come up, but it comes up if I click anywhere in the frame. I can disable the menu, and then in the right-click event of the widget, I enable it. This works very well the first time; if I click anywhere in the frame, nothing happens (the menu is diabled), but if I click on my widget, the menu is enabled and pops up. Yay! But now the menu is enabled and now it pops up if I right-click anywhere, on buttons, empty space, progress bars, etc. When do I disable it again? After the menu has popped up, the user can click anywhere and the menu will dissappear. There is no event that fires when the menu is closed, so I'm stuck.
Sorry about the long ramblings, I'll restate the question briefly: I want to have one popup menu that pops up when the user right-clicks one of a number of dynamically created widgets.
Using Tom's answer, this is how I implemented it:
/* Somewhere in Control Definitions... */
DEFINE MENU m_Popup
MENU-ITEM m_Test1 LABEL "Test 1"
MENU-ITEM m_Test2 LABEL "Test 2".
/* Somewhere, where I need to dynamically create the widgets. */
/* Loop through the items in the temp table and create a widget for each. */
FOR EACH ttItem BY ttItem.ItemName:
CREATE TOGGLE-BOX hWidget
ASSIGN
FRAME = FRAME DEFAULT-FRAME:HANDLE
LABEL = STRING(ttItem.ttItemName)
TRIGGERS:
ON MOUSE-MENU-DOWN PERSISTENT RUN GetMenu IN THIS-PROCEDURE.
END TRIGGERS.
END.
/* If the user right-clicks on any one of the widgets, this procedure */
/* is run with SELF being the widget that was clicked on. */
PROCEDURE GetMenu:
/* Remove the menu from its current owner and assign it to SELF. */
MENU m_Popup:OWNER:POPUP-MENU = ?.
SELF:POPUP-MENU = MENU m_Popup:HANDLE.
END PROCEDURE.
/* The user clicks on one of the menu items */
/* Here SELF is the menu item that was clicked. I can */
/* get m_Popup from SELF:PARENT and the widget it was */
/* was assigned to from SELF:PARENT:OWNER. */
ON CHOOSE OF MENU-ITEM m_Test1
DO:
MESSAGE "You selected " SELF:LABEL " for " SELF:PARENT:OWNER:LABEL.
END.
My buddy Mike Fechner (who is not currently on SO but who does this stuff a lot more than I do) tells me that, while this example is static, something very similar should work:
Procedure getMenu:
DEFINE INPUT PARAMETER phWidget AS HANDLE NO-UNDO.
DO WITH FRAME {&FRAME-NAME}:
FILL-IN-1:POPUP-MENU = ? .
FILL-IN-2:POPUP-MENU = ? .
FILL-IN-3:POPUP-MENU = ? .
END.
phWidget:POPUP-MENU = MENU POPUP-MENU-FILL-IN-1:HANDLE .
END procedure.
ON RIGHT-MOUSE-DOWN of all three fill-in’s you "RUN getMenu (SELF)." to steal the popup menu from whomever has it.