Skip to content

Triggers don’t work with actions that display a result #623

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
skurfer opened this issue Dec 16, 2011 · 2 comments
Closed

Triggers don’t work with actions that display a result #623

skurfer opened this issue Dec 16, 2011 · 2 comments
Assignees
Labels
Milestone

Comments

@skurfer
Copy link
Member

skurfer commented Dec 16, 2011

I’ve had a trigger for Current Selection → Use as Remote Host for a long time, but it’s never worked. I always thought it was proxy object weirdness, but I had an idea tonight. You can also reproduce this by creating a trigger for something like =15+10 → Calculate. As you’ll see, nothing happens. I’m pretty sure it has to do with the action having displaysResult set to true.

Maybe this only works when the interface was active to begin with? Haven’t had time to dig into it.

@ghost ghost assigned skurfer Jan 21, 2012
@skurfer
Copy link
Member Author

skurfer commented Jan 22, 2012

I’ve managed to fix this by changing QSCommand.m#403 from

return [actionObject performOnDirectObject:dObject indirectObject:iObject];

to

QSObject *returnValue = [actionObject performOnDirectObject:dObject indirectObject:iObject];
if (returnValue) {
    QSController *controller = [(QSController *)[NSApp delegate] interfaceController];
    // if the action returns something, wipe out the first pane
    /* (The main object would get replaced anyway. This is only done to
     remove objects selected by the comma trick before the action was run.) */
    [controller clearObjectView:[controller dSelector]];
    // put the result in the first pane and in the results list
    [[controller dSelector] performSelectorOnMainThread:@selector(setObjectValue:) withObject:returnValue waitUntilDone:YES];
    // bring the interface back to show the result
    if ([actionObject displaysResult]) {
        [controller actionActivate:nil];
    }
}
return returnValue;

Basically, I mimicked a lot of what you find in QSInterfaceController's executeCommandThreaded method.

I don't like the above fix because it duplicates so much code. Especially since the code comes from a method I've had to fix at least twice. If we ever had to fix it further, we'd have to remember to do it both places. So, I plan to look for a better long-term fix that consoldates all of this functionality into a single place that gets shared by all the various entry points.

Who knows? Maybe I'll accidentally fix #283 in the process.

@skurfer
Copy link
Member Author

skurfer commented Jan 25, 2012

Related to this, I’ve noticed that if you previously had multiple items selected with the comma trick, then you run a trigger that asks for something in the third pane, the other objects in the first pane won’t be properly cleared.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant