Enable/Disable all buttons under a parent Menu button in Journal Voucher in ax 2012 - dynamics-ax-2012-r2

I need to disable all the (child)buttons under a menu button(parent).
I need to use this in AccountsPayable->journals->paymentJournal->lines->JournalVoucher, here I want to disable all the child buttons of paymentStatus menu button, Later I'll enable the buttons what I require.
Is there any way, instead of hard coding for all the buttons as button_name.enable(false), In future I may add some more statuses under paymentStatus, so I need to disable all the child buttons without hard coding.

You could loop over the sub controls and disable them. Here a short example of a form's run method:
public void run()
{
int i;
super();
for (i = 1; i <= menuButton.controlCount(); ++i)
{
menuButton.controlNum(i).enabled(false);
}
}

Related

Automatically hiding a Qt QWidget after the user clicks elsewhere

I would like to create a QWidget that acts like a pop-up, and I am having trouble figuring out how to do it.
I want to create a sidebar/drawer that gets shown when the user clicks a button. The user will briefly interact with child widgets of the sidebar. The tricky part is that I want the sidebar to be hidden automatically when the user clicks elsewhere in the application. Worst case I can require the user to manually toggle the sidebar, but automatically hiding it is convenient.
I tried or investigated:
Setting the Qt::Popup window flag, but the sidebar needs to be a widget, not a separate window.
Listening for focus events, but I want to support keyboard navigation. The user should be able to Tab to other widgets while the sidebar remains visible. The sidebar should be hidden when the user actually interacts with the other widgets (such as hitting Enter).
Adding an event filter on the top-level widget, but it doesn't receive events that occur on its children (such as a button being clicked).
Adding an invisible "overlay" widget over the rest of the application, but I want the user to be able to directly click on other widgets. Capturing clicks in the invisible overlay would require the user to click twice (once to clear the overlay, then again to interact with other widgets).
Is this just not feasible?
One possibility might be to install an event filter on the QApplication instance itself. Note, though, that application wide event filters can have a noticeable performance impact so it should only be installed as/when necessary. A mock-up might look something like...
class sidebar: public QWidget {
using super = QWidget;
protected:
virtual bool eventFilter (QObject *obj, QEvent *event) override
{
/*
* Your stuff goes here...
*/
if (auto *widget = dynamic_cast<QWidget *>(obj)) {
if (isAncestorOf(widget)) {
/*
* obj refers to a QWidget of some description that is
* a child of this sidebar instance.
*/
} else {
/*
* widget _isn't_ a child of this sidebar so may need
* to take action (including hiding) depending on the
* specifics of widget and the event details.
*/
}
}
return super::eventFilter(obj, event);
}
virtual void showEvent (QShowEvent *event) override
{
super::showEvent(event);
qApp->installEventFilter(this);
}
virtual void hideEvent (QHideEvent *event) override
{
super::hideEvent(event);
qApp->removeEventFilter(this);
}
};
Will require a certain amount of experimentation obviously :-)

Interaction with parent control triggers RippleDrawable in Xamarin.Forns custom renderer

I have implemented a custom clickable label class in Xamarin.Forms along with a custom renderer, that adds a RippleDrawable as the controls Foreground. I am creating the RippleDrawable with the following code:
public static Drawable CreateRippleDrawable(Context context)
{
var typedValue = new TypedValue();
context.Theme.ResolveAttribute(Resource.Attribute.SelectableItemBackground, typedValue, true);
var rippleDrawable = context.Resources.GetDrawable(typedValue.ResourceId, context.Theme);
return rippleDrawable;
}
In my custom renderer I assign the drawable
this.Control.Foreground = DrawableHelper.CreateRippleDrawable(this.Context);
and update the ripple when the user touches the control
private void LinkLabelRenderer_Touch(object sender, TouchEventArgs e)
{
if (e.Event.Action == MotionEventActions.Down)
{
this.Pressed = true;
}
if (e.Event.Action == MotionEventActions.Cancel)
{
this.Pressed = false;
}
if (e.Event.Action == MotionEventActions.Up)
{
this.Ripple.SetHotspot(e.Event.GetX(), e.Event.GetY());
this.Pressed = false;
// raise the event of the Xamarin.Forms control
}
}
Now, whenever I click the control, the ripple will be shown, which is the expected behavior, but if I touch (tap or long-press) the parents of the control (e.g. the StackLayout, Grid or whatever layout contains the label, including their parent Layout, Page or View) the ripple animation will be triggered. Anyway, the event handler LinkLabelRenderer_Touch in not called in this case, only when the actual control is touched.
I can work around this behavior by adding an empty GestureRecognizer to the respective parent(s), but I really dislike this solution, because this is but a hack. And to make things worse it is a hack I'll always have to remember whenever I use the control.
How can I prevent the RippleDrawable being shown when the parent is touched?
Turned out I got things fundamentally wrong. Subscribing the Touch event is not the way to go. I had to make the control clickable and subscribe the Click event
this.Control.Clickable = true;
this.Click += LinkLabelRenderer_OnClick;
There is no need to handle all that RippleTouch stuff the way I did (via the Touch event) but could let android handle things for me.

Xamarin Forms - How to do navigation without return

I have two pages: Page A and Page B. I want that the user on my application be able to pass since page A to page B, but I don,t want he to be able to pass since page B to page A. How can I do that?
I tryed to use Navigation Page and deactivate the return Button, but I couldn't find how deactivate it.
If you don't need to "Navigate" you can set
Application.Current.MainPage = new PageB();
and override OnBackButtonPressed()
protected override void OnDisappearing()
{
//back button logic here
return true;
}

WatchKit - Force Touch API Questions

Some questions to the Force Touch Menu:
Now when I perform a Force Touch and press one of my menu Items, the whole InterfaceController, where my Menu is implemented is loading new.
Is this avoidable?
I've implemented a menu with 4 menuItems for my InterfaceController.
With one of this menuItems, I want to enable/disable the haptic Feedback of my Buttons.
My button methods are like this:
- (IBAction) but1Pressed {
[[WKInterfaceDevice currentDevice] playHaptic:WKHapticType.Click];
// Do something
}
How can I disable the TapticEngine, if the user disables it ind the ForceTouchMenu?
No, as by today that's not possible.
If I understand you properly, you need a BOOL which defines whether the app should perform haptic feedback when a button in your interface controller is being pressed.
To realise that, implement the following:
BOOL shouldGiveTapticFeedback = YES
Then you need a method to change this BOOL when the corresponding menu item is being pressed:
- (IBAction) tapticFeedbackChangeButtonPressed {
//change BOOL value
shouldGiveTapticFeedback = !shouldGiveTapticFeedback
}
Finally, you need to check whether the taptic feedback should be played, when a button in your interface controller is being pressed:
- (IBAction) interfaceButtonPressed {
if(shouldGiveTapticFeedback) {
//play sound
[[WKInterfaceDevice currentDevice] playHaptic:WKHapticType.Click];
}
}
No, that's not possible either.

How to disable delete button in ASP.NET Dynamic Data?

I need to disable delete button GLOBALLY based on some condition?
The following solutions will not work for me:
http://csharpbits.notaclue.net/2009/07/securing-dynamic-data-preview-4-refresh.html
http://csharpbits.notaclue.net/2008/05/dynamicdata-miscellaneous-bits-part-6.html
Again, I do not want to go into every list and detail page and disable it there.
Why not just extend/inherit from button. You could make your own button that "knows" how to check if it should be hidden:
public class MyButton : Button
{
public void HiddenCheck()
{
bool visible = true;
//Check to see if the button should be hidden
this.Visible = visible;
}
}
Then, just use this button instead of the "System.Web.UI.WebControls.Button" button wherever you need the delete button functionality.
-Make that "Enabled." I read the post again, and I guess you aren't trying to "hide" the button, but disable it. The idea is the same though.

Resources