Positioning with number values - triggered by adjacent letters?

Is it possible to code a font so that it knows what the adjacent letters are and then repositions letters by number values?

Worked through the tutorial here: https://glyphsapp.com/learn/positioning-with-number-values

I have a vertical bar with a top at Cap height, and a bottom that descends below baseline. This looks great next to lowercase letters, but next to uppercase, I’d like it to be positioned a little higher.

So created a class called “Bar” and a Case-sensitive form of:
pos @bar <10 108 10 0>;

Testing it in InDesign, if I set it to all caps (Command shift K), it works perfectly. But if I just hit the shift key or caps lock key, it reverts to the lower position.

Is there a way to have the font be aware of what the letter before was? Uppercase = higher, lowercase = regular.

Here’s the actual glyph - descends below baseline, but top is at Cap height.

I’m fairly new to Glyphs, and not much of a coder. Perhaps my approach on this is all wrong and I should create alternate glyphs? Can a font “see” the letter that came before and then adjust based upon that?

I should also mention that I absolutely love working in Glyphs, and have found this community to be positive and encouraging. Thanks to all!

Consider a bar.case and update opentype features. You can do something similar with other punctuation.

Or a compromise design that is acceptable in both contexts.

All other solutions seem overkill for the vertical bar.

I think you need some contextual positioning or substitution. Search for “context” on this page: Rules