Genexus - Disable Text Block used as button - button

I have a Text Block that I use as a button (with enter event) and when I press it it takes a while to do what it has to do, so you can click more than once the button and it does it twice or more times. So what I want to do is to disable or to hide the text block while its doing its job, but the text block only hides when it exits the enter event, which is to late because I already could pressed several times the buttom.
How can I find a solution for this? Is there a way to disable or hide the text block when I enter the enter event but before it exit the event?

I suppose you are calling a procedure. Try to use
MyProcedure.Submit()
instead of
MyProcedure.Call()

Related

Hiding text in a button

I have a certain set of buttons registered so that they can be executed using letters in a keyboard or by mouse click. But I want to hide the text in the button from the user so that it looks more natural.
Heres part of the code:
ToggleButton btn1 = new ToggleButton("");
btn1.setMnemonicParsing(true); // instruction to parse mnemonic
btn1.setText("_7");
Now instead of the button showing a 7 in the middle I want it to be hidden but still function the same. I have a feeling it has something to do with the setVisible() method but I'm not sure how to use it for just the text inside the button instead of the entire button itself.
Most probably you can't do both at the same time. If you want to trigger the button using MneomonicParsing, then you have set the text and it will be visible in the button.
Why don't you use a onKeyPressed method of the container of those buttons instead? Then you don't have to set any text on the button. Like this:
container.setOnKeyPressed(k->{
switch(k.getCode()){
case NUMPAD7:
case DIGIT7: btn1.fire();
break;
//implement other cases
}
});

wxPython issue in changing button text

I am working on a wxPython app where I have a button with label text 'Allocate'. Additionally I also have 2 radio options on my app namely 'UnAllocated' and 'Allocated'. When the app launches by default the radio option 'UnAllocated' is selected and the button has label text as 'Allocate'. I have made event driven code to change the label text of the button from 'Allocate' to 'Re-Allocate' upon selecting the radio option 'Allocated'. Uptill now everything is fine and code works as intended.
Now the problem is in the event of radio option 'Allocated' the button label does gets a new label text as 'Re-Allocate' however it is overwriting the previous label text instead of changing. Then as soon as I bring my mouse cursor on the button the text gets refreshed and appears clean and clear. Below is my Code
def rdoAllocated_Click(self, event):
self.btn_Allocate.SetLabelText('Re-Allocate')
def rdoUnAllocated_Click(self, event):
self.btn_Allocate.SetLabelText('Allocate')
is there a way of refreshing the button label text automatically after the change to display clearly the new text instead of unreadable overwritten text.
Here is the image how it looks when getting updated
Try calling self.btn_Allocate.Refresh() This can happen sometimes, depending on platform and widget types. The Refresh simply tells the system to send a paint event in the near future, and will most-likely take care of the problem for you. If not then you may need to call the parent window's Refresh instead.

No event getting generated on button click in MFC

I have a dialog based application. I have one static text control and a button on this, both of which I have made invisible in the beginning. I want to show both the controls on reaching a certain condition. When I click this button, again I want to make both the controls invisible.
However, I am able to show and hide the control and also captured the button click event like this:
ON_BN_CLICKED(IDC_MY_BUTTON, &MyDlg::OnBnClickedMyButton)
and defined OnBnClickedMyButton().
But when I press the button, it is not pressed and the event is also not generated.
Any suggestions?
First check if the IDC_MY_BUTTON exists and is valid.
Remember to add DECLARE_MESSAGE_MAP() at the header file.
Also check at the BEGIN_MESSAGE_MAP(MyClass,MyParentClass) if the class
and the parent class you write are right.
I hope this helps.
I think the IDC_MY_BUTTON maybe is invalid or other control has the same ID.
Well, finally I have come to know that though the button was visible but on clicking it was not taking control, hence I used BringWindowToTop() to draw it on top. Now it is being clicked and OnBnClickedMyButton() is also being called.
But now the issue is that after calling BringWindowToTop() the button is not shown. It is shown only when I take the mouse pointer on it. Not able to understand what is the issue.

Button text change from another activity

I'm having problem in changing the text of a button in main activity. I want to change the text of that button upon click on another button which is in second activity. Please help me with the solution?
There are many ways to do it but simplest way to do it is- You can maintain a static boolean variable in any of your activity and change its value to true on the button click of your other activity and whenever your AainActivity resumes you can check in its onResume() method for this variable and if it is true -> change the text of your button in MainActivity.

Custom TextInput component loses focus but still contains cursor?

I have a custom TextInput that listens for the FocusEvent.FOCUS_IN and FocusEvent.FOCUS_OUT events:
textDisplay.addEventListener(FocusEvent.FOCUS_IN, onFocusInHandler);
textDisplay.addEventListener(FocusEvent.FOCUS_OUT, onFocusOutHandler);
My onFocusInHandler function basically removes a "promptview" that tells the user to type in a value, with the onFocusOutHandler doing the opposite.
For example, if the TextInput text was backspaced to a blank value and the user clicks out of the TextInput box, it would show a "Please enter a value" light-gray prompt in the TextInput.
This works fine until the user clicks our custom "Clear" button. The clear button sets the text to "", and I can tell the FocusEvent.FOCUS_OUT is received because the prompt text is set to visible (its not being set anywhere else). The problem is, the cursor remains in the box as if it still has focus, so if the user immediately starts typing, both the prompt text "Please enter a value" and the user-entered text appears over the gray text, which looks pretty ugly and unreadable.
Why does the TextInput receive the FocusEvent.FOCUS_OUT event if it's not actually losing focus? Is there any way I can get around this?
Option 1. Use the Spak TextInput in Flex 4.1 or 4.5. This already provides a promptDisplay by default (as mentioned in the comments)
Option 2. Take a look at the focus-skin. This skin class is usually placed on top of the normal skin. There could exist some focus ambiguity between these two. Try using a custom focus-skin without a textDisplay and clear button.
Option 3. Not only use a focus event to show or hide the prompt, but also look at the content of the TextInput. You don't want to display a prompt when the text is set by binding as wel.

Resources